Cosmic Ray Report

Date time: 17/10/2025 08:32:48

Total jobs: 2737

Complete: 2737 (100.00%)

Surviving mutants: 1266 (46.26%)

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) + 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() + start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() + start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002815878737Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002816843900Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.29s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() + start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.99s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() + start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041104871909Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041106063598Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 21.41s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() + _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T005143211686Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T005144142001Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.41s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) * 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.02s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() * start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() * start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.63s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() * start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061434372220Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061435219157Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.87s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() * start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eddcd781321896b72: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.83s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() * _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.80s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) / 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.36s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() / start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002509593209Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002510631075Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.44s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() / start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.78s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() / start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() / start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() / _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.90s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) // 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() // start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() // start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() // start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e7e8e4456f9799de0: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.91s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() // start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.39s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() // _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.77s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) % 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142557952503Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142558960779Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

10 failed, 4 passed, 22 warnings in 20.44s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() % start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053046906206Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053047850686Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.83s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() % start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() % start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155705530425Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155706412793Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.39s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() % start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() % _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T153913260140Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T153914148572Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.20s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) ** 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() ** start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() ** start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
.F............                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (34, 'Result too large')

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

1 failed, 13 passed, 22 warnings in 20.69s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() ** start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T173127700387Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T173128553594Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.89s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() ** start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
...F......F...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() ** start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^^

E       OverflowError: (34, 'Result too large')



server.py:401: OverflowError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() ** start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^^

E       OverflowError: (34, 'Result too large')



server.py:401: OverflowError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OverflowError: (34, ...

FAILED ..\test\test_api.py::test_read_watermark_route - OverflowError: (34, '...

2 failed, 12 passed, 22 warnings in 21.14s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() ** _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: (34, 'Result too large')

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.22s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) >> 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.55s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() >> start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.33s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() >> start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
.F............                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for >>: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

1 failed, 13 passed, 22 warnings in 20.40s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() >> start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003615492719Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003616408221Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.52s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() >> start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
...F......F...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() >> start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



server.py:401: TypeError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() >> start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



server.py:401: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

2 failed, 12 passed, 22 warnings in 19.77s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() >> _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for >>: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 19.95s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) << 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e33f14556adcf53bd: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.68s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() << start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() << start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
.F.F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() << start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/login")

    def login():

        payload = request.get_json(silent=True) or {}

        email = (payload.get("email") or "").strip()

        password = payload.get("password") or ""

    

        if not email or not password:

            app.logger.warning("Missing fields in login attempt: %s", payload)

            return jsonify({"error": "email and password are required"}), 400

    

        start_db = time.time()

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        "SELECT id, email, login, hpassword FROM Users "

                        "WHERE email = :email LIMIT 1"

                    ),

                    {"email": email},

                ).first()

    

                # Constant-time comparison to prevent timing attacks

                if row:

                    is_valid = check_password_hash(row.hpassword, password)

                else:

                    # Dummy check to maintain constant time

                    is_valid = False

                    row = None

    

                if not is_valid:

                    app.logger.warning(

                        "Failed login attempt for email: %s",

                        email if email else "<empty>",

                    )

                    inc_login_failure("invalid_credentials")

                    return jsonify({"error": "invalid credentials"}), 401

    

        except Exception as e:

            app.logger.error("Database error in login: %s", e)

            inc_db_error("login_select")

            return jsonify({"error": "An error occurred"}), 503

    

>       observe_db_latency("login_select", time.time() << start_db)

                                           ^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



server.py:284: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

1 failed, 13 passed, 22 warnings in 20.77s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() << start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
...F......F...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() << start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



server.py:401: TypeError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() << start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



server.py:401: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

2 failed, 12 passed, 22 warnings in 20.69s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() << _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for <<: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.24s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) | 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T024108036724Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T024108910263Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.27s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() | start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.03s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() | start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T060406351161Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T060407267731Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.27s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() | start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..FF.....FFF.F                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/login")

    def login():

        payload = request.get_json(silent=True) or {}

        email = (payload.get("email") or "").strip()

        password = payload.get("password") or ""

    

        if not email or not password:

            app.logger.warning("Missing fields in login attempt: %s", payload)

            return jsonify({"error": "email and password are required"}), 400

    

        start_db = time.time()

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        "SELECT id, email, login, hpassword FROM Users "

                        "WHERE email = :email LIMIT 1"

                    ),

                    {"email": email},

                ).first()

    

                # Constant-time comparison to prevent timing attacks

                if row:

                    is_valid = check_password_hash(row.hpassword, password)

                else:

                    # Dummy check to maintain constant time

                    is_valid = False

                    row = None

    

                if not is_valid:

                    app.logger.warning(

                        "Failed login attempt for email: %s",

                        email if email else "<empty>",

                    )

                    inc_login_failure("invalid_credentials")

                    return jsonify({"error": "invalid credentials"}), 401

    

        except Exception as e:

            app.logger.error("Database error in login: %s", e)

            inc_db_error("login_select")

            return jsonify({"error": "An error occurred"}), 503

    

>       observe_db_latency("login_select", time.time() | start_db)

                                           ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



server.py:284: TypeError

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e5dc1d50c8fa83b5c: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

6 failed, 8 passed, 22 warnings in 20.11s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() | start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T015934859041Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T015935779550Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.32s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() | _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171318917099Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171319767067Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.24s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) & 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.....F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

5 failed, 9 passed, 22 warnings in 19.29s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() & start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() & start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
.F............                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for &: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

1 failed, 13 passed, 22 warnings in 21.59s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() & start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/login")

    def login():

        payload = request.get_json(silent=True) or {}

        email = (payload.get("email") or "").strip()

        password = payload.get("password") or ""

    

        if not email or not password:

            app.logger.warning("Missing fields in login attempt: %s", payload)

            return jsonify({"error": "email and password are required"}), 400

    

        start_db = time.time()

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        "SELECT id, email, login, hpassword FROM Users "

                        "WHERE email = :email LIMIT 1"

                    ),

                    {"email": email},

                ).first()

    

                # Constant-time comparison to prevent timing attacks

                if row:

                    is_valid = check_password_hash(row.hpassword, password)

                else:

                    # Dummy check to maintain constant time

                    is_valid = False

                    row = None

    

                if not is_valid:

                    app.logger.warning(

                        "Failed login attempt for email: %s",

                        email if email else "<empty>",

                    )

                    inc_login_failure("invalid_credentials")

                    return jsonify({"error": "invalid credentials"}), 401

    

        except Exception as e:

            app.logger.error("Database error in login: %s", e)

            inc_db_error("login_select")

            return jsonify({"error": "An error occurred"}), 503

    

>       observe_db_latency("login_select", time.time() & start_db)

                                           ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



server.py:284: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

1 failed, 13 passed, 22 warnings in 20.34s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() & start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
...F......F...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() & start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



server.py:401: TypeError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() & start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



server.py:401: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

2 failed, 12 passed, 22 warnings in 21.27s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() & _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for &: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.00s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) ^ 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.84s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() ^ start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() ^ start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
.F............                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for ^: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

1 failed, 13 passed, 22 warnings in 21.75s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() ^ start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/login")

    def login():

        payload = request.get_json(silent=True) or {}

        email = (payload.get("email") or "").strip()

        password = payload.get("password") or ""

    

        if not email or not password:

            app.logger.warning("Missing fields in login attempt: %s", payload)

            return jsonify({"error": "email and password are required"}), 400

    

        start_db = time.time()

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        "SELECT id, email, login, hpassword FROM Users "

                        "WHERE email = :email LIMIT 1"

                    ),

                    {"email": email},

                ).first()

    

                # Constant-time comparison to prevent timing attacks

                if row:

                    is_valid = check_password_hash(row.hpassword, password)

                else:

                    # Dummy check to maintain constant time

                    is_valid = False

                    row = None

    

                if not is_valid:

                    app.logger.warning(

                        "Failed login attempt for email: %s",

                        email if email else "<empty>",

                    )

                    inc_login_failure("invalid_credentials")

                    return jsonify({"error": "invalid credentials"}), 401

    

        except Exception as e:

            app.logger.error("Database error in login: %s", e)

            inc_db_error("login_select")

            return jsonify({"error": "An error occurred"}), 503

    

>       observe_db_latency("login_select", time.time() ^ start_db)

                                           ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



server.py:284: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

1 failed, 13 passed, 22 warnings in 20.94s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() ^ start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
...F......F...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() ^ start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



server.py:401: TypeError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() ^ start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



server.py:401: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

2 failed, 12 passed, 22 warnings in 20.09s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() ^ _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ^: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.34s

operator: core/ReplaceBinaryOperator_Mul_Add, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 + 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceBinaryOperator_Mul_Add, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 + 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.41s

operator: core/ReplaceBinaryOperator_Mul_Add, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 + 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1cb270defc925f30: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.61s

operator: core/ReplaceBinaryOperator_Mul_Sub, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 - 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/ReplaceBinaryOperator_Mul_Sub, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 - 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/ReplaceBinaryOperator_Mul_Sub, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 - 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T181630941015Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T181631906023Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.76s

operator: core/ReplaceBinaryOperator_Mul_Div, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 / 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:360: in upload_document

    sha_hex = _sha256_file(stored_path)

              ^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:130: in _sha256_file

    for chunk in iter(lambda: f.read(1024 / 1024), b""):

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



>   for chunk in iter(lambda: f.read(1024 / 1024), b""):

                              ^^^^^^^^^^^^^^^^^^^

E   TypeError: argument should be integer or None, not 'float'



server.py:130: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:360: in upload_document

    sha_hex = _sha256_file(stored_path)

              ^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:130: in _sha256_file

    for chunk in iter(lambda: f.read(1024 / 1024), b""):

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



>   for chunk in iter(lambda: f.read(1024 / 1024), b""):

                              ^^^^^^^^^^^^^^^^^^^

E   TypeError: argument should be integer or None, not 'float'



server.py:130: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: argument ...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: argument s...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.57s

operator: core/ReplaceBinaryOperator_Mul_Div, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 / 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.46s

operator: core/ReplaceBinaryOperator_Mul_Div, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 / 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e29bb39ba4e673a94: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.79s

operator: core/ReplaceBinaryOperator_Mul_FloorDiv, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 // 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/ReplaceBinaryOperator_Mul_FloorDiv, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 // 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.02s

operator: core/ReplaceBinaryOperator_Mul_FloorDiv, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 // 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.54s

operator: core/ReplaceBinaryOperator_Mul_Mod, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 % 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193251171613Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193252094837Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.63s

operator: core/ReplaceBinaryOperator_Mul_Mod, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 % 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/ReplaceBinaryOperator_Mul_Mod, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 % 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.29s

operator: core/ReplaceBinaryOperator_Mul_Pow, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 ** 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:360: in upload_document

    sha_hex = _sha256_file(stored_path)

              ^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:130: in _sha256_file

    for chunk in iter(lambda: f.read(1024 ** 1024), b""):

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



>   for chunk in iter(lambda: f.read(1024 ** 1024), b""):

                              ^^^^^^^^^^^^^^^^^^^^

E   OverflowError: cannot fit 'int' into an index-sized integer



server.py:130: OverflowError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:360: in upload_document

    sha_hex = _sha256_file(stored_path)

              ^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:130: in _sha256_file

    for chunk in iter(lambda: f.read(1024 ** 1024), b""):

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



>   for chunk in iter(lambda: f.read(1024 ** 1024), b""):

                              ^^^^^^^^^^^^^^^^^^^^

E   OverflowError: cannot fit 'int' into an index-sized integer



server.py:130: OverflowError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OverflowError: canno...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - OverflowError: cannot...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 20.38s

operator: core/ReplaceBinaryOperator_Mul_Pow, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 ** 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F......F...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 201 == 413

E            +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:181: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

>           assert upload_resp_data.get("id") == 2

E           AssertionError: assert 3 == 2

E            +  where 3 = <built-in method get of dict object at 0x000001C9E6BD2940>('id')

E            +    where <built-in method get of dict object at 0x000001C9E6BD2940> = {'creation': '2025-10-17T00:22:49.954706', 'id': 3, 'name': 'Water File', 'sha256': '5FBAC867F5EFDD7B0AB5C11456B204DDD08FF8801502C93728BE3B38BFAFE80C', ...}.get



..\test\test_api.py:390: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 201 == 413

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

2 failed, 12 passed, 22 warnings in 20.44s

operator: core/ReplaceBinaryOperator_Mul_Pow, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 ** 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F......F...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 201 == 413

E            +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:181: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

>           assert upload_resp_data.get("id") == 2

E           AssertionError: assert 3 == 2

E            +  where 3 = <built-in method get of dict object at 0x000002021F3DCF80>('id')

E            +    where <built-in method get of dict object at 0x000002021F3DCF80> = {'creation': '2025-10-16T18:16:11.258705', 'id': 3, 'name': 'Water File', 'sha256': '5FBAC867F5EFDD7B0AB5C11456B204DDD08FF8801502C93728BE3B38BFAFE80C', ...}.get



..\test\test_api.py:390: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 201 == 413

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

2 failed, 12 passed, 22 warnings in 20.88s

operator: core/ReplaceBinaryOperator_Mul_RShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 >> 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ReplaceBinaryOperator_Mul_RShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 >> 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.08s

operator: core/ReplaceBinaryOperator_Mul_RShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 >> 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.96s

operator: core/ReplaceBinaryOperator_Mul_LShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 << 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:360: in upload_document

    sha_hex = _sha256_file(stored_path)

              ^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:130: in _sha256_file

    for chunk in iter(lambda: f.read(1024 << 1024), b""):

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



>   for chunk in iter(lambda: f.read(1024 << 1024), b""):

                              ^^^^^^^^^^^^^^^^^^^^

E   OverflowError: cannot fit 'int' into an index-sized integer



server.py:130: OverflowError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:360: in upload_document

    sha_hex = _sha256_file(stored_path)

              ^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:130: in _sha256_file

    for chunk in iter(lambda: f.read(1024 << 1024), b""):

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



>   for chunk in iter(lambda: f.read(1024 << 1024), b""):

                              ^^^^^^^^^^^^^^^^^^^^

E   OverflowError: cannot fit 'int' into an index-sized integer



server.py:130: OverflowError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OverflowError: canno...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - OverflowError: cannot...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 20.36s

operator: core/ReplaceBinaryOperator_Mul_LShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 << 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 500 == 413

E            +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:181: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 413

1 failed, 13 passed, 22 warnings in 20.65s

operator: core/ReplaceBinaryOperator_Mul_LShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 << 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223706838979Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223707695486Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.66s

operator: core/ReplaceBinaryOperator_Mul_BitOr, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 | 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 28.32s

operator: core/ReplaceBinaryOperator_Mul_BitOr, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 | 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/ReplaceBinaryOperator_Mul_BitOr, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 | 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/ReplaceBinaryOperator_Mul_BitAnd, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 & 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.08s

operator: core/ReplaceBinaryOperator_Mul_BitAnd, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 & 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.45s

operator: core/ReplaceBinaryOperator_Mul_BitAnd, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 & 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.95s

operator: core/ReplaceBinaryOperator_Mul_BitXor, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 ^ 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001746206839Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001747203540Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.49s

operator: core/ReplaceBinaryOperator_Mul_BitXor, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 ^ 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T192520029090Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T192521036962Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 20.07s

operator: core/ReplaceBinaryOperator_Mul_BitXor, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 ^ 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e75078809e14e60b2: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.78s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] + "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] + "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] + "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.99s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" + g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" + g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" + g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.89s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir + stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for +: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for +: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.20s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root + fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.92s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root + file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.56s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent + "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent + "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 13 passed, 22 warnings in 20.66s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir + candidate
 
         # write bytes
         try:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T023210333671Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T023211309238Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.34s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root + file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.13s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] - "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] - "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] - "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 20.34s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" - g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" - g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" - g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.66s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir - stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for -: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for -: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 20.15s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root - fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root - file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.91s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent - "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent - "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 13 passed, 22 warnings in 20.60s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir - candidate
 
         # write bytes
         try:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir - candidate

                    ^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'WindowsPath' and 'str'



server.py:1049: TypeError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec5ee0ad9274a47b1: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.91s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root - file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.70s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] * "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] * "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'WindowsPath'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] * "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'WindowsPath'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: can't mul...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: can't mult...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.42s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" * g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" * g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'WindowsPath'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" * g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'WindowsPath'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: can't mul...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: can't mult...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.84s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir * stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: can't multiply sequence by non-int of type 'WindowsPath'

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: can't multiply sequence by non-int of type 'WindowsPath'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.81s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root * fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.03s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root * file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e82477b8885eeb69a: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.73s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent * "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent * "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'WindowsPath'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: can't mu...

1 failed, 13 passed, 22 warnings in 21.59s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir * candidate
 
         # write bytes
         try:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir * candidate

                    ^^^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'WindowsPath'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: can't mu...

1 failed, 13 passed, 22 warnings in 20.97s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root * file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212446329083Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212447309043Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.35s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] // "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] // "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] // "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.30s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" // g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" // g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" // g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.26s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir // stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for //: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for //: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.16s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root // fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root // file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent // "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent // "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'WindowsPath' and 'str'



server.py:1045: TypeError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e9ed6a6d91db82f84: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.63s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir // candidate
 
         # write bytes
         try:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir // candidate

                    ^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 13 passed, 22 warnings in 20.12s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root // file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T163523937722Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T163524862022Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.33s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] % "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] % "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] % "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.45s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" % g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" % g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" % g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.48s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir % stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for %: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for %: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.45s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root % fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root % file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent % "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent % "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 13 passed, 22 warnings in 20.45s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir % candidate
 
         # write bytes
         try:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir % candidate

                    ^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 13 passed, 22 warnings in 20.50s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root % file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e0d1a5c366ed7a13f: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.64s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] ** "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] ** "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] ** "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.47s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" ** g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" ** g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" ** g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.36s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir ** stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.98s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root ** fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.99s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root ** file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent ** "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent ** "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 13 passed, 22 warnings in 20.14s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir ** candidate
 
         # write bytes
         try:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir ** candidate

                    ^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 13 passed, 22 warnings in 20.75s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root ** file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.27s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] >> "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] >> "files" / g.user["login"]

                                                ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] >> "files" / g.user["login"]

                                                ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" >> g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" >> g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" >> g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.64s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir >> stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for >>: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for >>: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.32s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root >> fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root >> file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.49s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent >> "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T200137592728Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T200138534820Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.82s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir >> candidate
 
         # write bytes
         try:
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root >> file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.46s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] << "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] << "files" / g.user["login"]

                                                ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] << "files" / g.user["login"]

                                                ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.64s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" << g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" << g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" << g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.79s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir << stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for <<: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for <<: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.32s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root << fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root << file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T182428926754Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T182430081237Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 20.50s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent << "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T051745848196Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T051746811592Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.74s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir << candidate
 
         # write bytes
         try:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035048357316Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035049260875Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.91s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root << file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.35s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] | "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] | "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] | "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.94s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" | g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" | g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" | g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.30s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir | stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for |: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for |: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.19s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root | fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root | file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.43s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent | "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
...F.....F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent | "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

2 failed, 12 passed, 22 warnings in 20.04s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir | candidate
 
         # write bytes
         try:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir | candidate

                    ^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 13 passed, 22 warnings in 20.49s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root | file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] & "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] & "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] & "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.38s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" & g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" & g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" & g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 20.44s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir & stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for &: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for &: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 21.31s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root & fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.29s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root & file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.75s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent & "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent & "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 13 passed, 22 warnings in 20.22s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir & candidate
 
         # write bytes
         try:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025730743552Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025731716133Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.31s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root & file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.01s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] ^ "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] ^ "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] ^ "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.55s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" ^ g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" ^ g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" ^ g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir ^ stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for ^: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for ^: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.21s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root ^ fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root ^ file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.85s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent ^ "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent ^ "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 13 passed, 22 warnings in 20.22s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir ^ candidate
 
         # write bytes
         try:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir ^ candidate

                    ^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 13 passed, 22 warnings in 20.35s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root ^ file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.19s

operator: core/ReplaceBinaryOperator_Pow_Add, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2+63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T062002542944Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T062003422700Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.07s

operator: core/ReplaceBinaryOperator_Pow_Sub, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2-63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.....F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

5 failed, 9 passed, 22 warnings in 20.03s

operator: core/ReplaceBinaryOperator_Pow_Mul, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2*63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.76s

operator: core/ReplaceBinaryOperator_Pow_Div, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2/63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.....F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

5 failed, 9 passed, 22 warnings in 19.56s

operator: core/ReplaceBinaryOperator_Pow_FloorDiv, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2//63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T222931859705Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T222932657315Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

10 failed, 4 passed, 22 warnings in 19.68s

operator: core/ReplaceBinaryOperator_Pow_Mod, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2%63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.....F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        #extract data

        doc_list = resp_data.get("versions")

        assert isinstance(doc_list, list)

        #cycle through each element in the list

        for elem in doc_list:

            assert isinstance(elem.get("id"), str)

            assert isinstance(elem.get("documentid"), str)

            #check the version is from the correct document

            assert elem.get("documentid") == str(parameters["documentid"])

            assert isinstance(elem.get("link"), str)

            assert isinstance(elem.get("intended_for"), str)

            assert isinstance(elem.get("secret"), str)

            assert isinstance(elem.get("method"), str)

    

        #Test with no parameters

        resp = client.get("/api/list-versions")

        assert resp.status_code == 400

        #Test with json parameters

        resp = client.get("/api/list-versions", json = parameters)

        assert resp.status_code == 400

        #Test with wrong parameters (missing file)

        resp = client.get("/api/list-versions", query_string = {'documentid': 4})

>       assert resp.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:245: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

WARNING  server:server.py:463 Invalid document id in query

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        #Test with no parameters

        resp = client.get("/api/get-document")

        assert resp.status_code == 400

        #Test with json parameters

        resp = client.get("/api/get-document", json = parameters)

        assert resp.status_code == 400

        #Test with wrong parameters (missing file)

        resp = client.get("/api/get-document", query_string = {'documentid': 4})

>       assert resp.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:293: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

WARNING  server:server.py:580 Invalid document id in query

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

>       assert resp.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:350: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 404

FAILED ..\test\test_api.py::test_get_document_route - assert 400 == 404

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 404

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

5 failed, 9 passed, 22 warnings in 19.82s

operator: core/ReplaceBinaryOperator_Pow_RShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2>>63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
...F.F.F.FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_Pow_LShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2<<63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.67s

operator: core/ReplaceBinaryOperator_Pow_BitOr, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2|63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T233053018443Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T233054023778Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.64s

operator: core/ReplaceBinaryOperator_Pow_BitAnd, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2&63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231303328255Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231304230668Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

8 failed, 6 passed, 22 warnings in 19.24s

operator: core/ReplaceBinaryOperator_Pow_BitXor, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2^63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.80s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int + None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int + None = None):

                                   ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T19:47:36+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:47:36+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T19:47:37+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:47:37+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.04s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int + None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int + None = None):

                                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T19:32:36+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:32:36+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T19:32:37+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:32:37+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.12s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int + None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int + None = None):

                                     ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T16:46:59+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T16:46:59+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T16:47:00+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T16:47:00+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.20s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int + None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int + None = None):

                                      ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T18:00:49+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:00:49+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T18:00:50+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:00:50+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.14s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes + bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for +: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.72s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int + None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int + None = None):

                                    ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T08:01:30+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T08:01:30+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T08:01:31+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T08:01:31+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.29s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int - None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int - None = None):

                                   ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T22:38:50+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T22:38:50+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T22:38:51+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T22:38:51+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.39s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int - None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int - None = None):

                                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T03:38:29+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:38:29+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T03:38:30+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:38:30+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.05s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int - None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int - None = None):

                                     ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T20:29:41+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T20:29:41+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T20:29:42+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T20:29:42+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.79s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int - None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int - None = None):

                                      ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T01:42:44+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T01:42:44+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T01:42:45+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T01:42:45+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.09s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes - bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for -: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.40s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int - None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int - None = None):

                                    ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T06:21:45+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T06:21:45+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T06:21:46+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T06:21:46+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.52s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int * None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int * None = None):

                                   ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T03:05:16+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:05:16+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T03:05:18+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:05:19+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 14.95s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int * None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int * None = None):

                                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T22:47:22+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T22:47:22+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T22:47:23+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T22:47:23+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.35s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int * None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int * None = None):

                                     ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T08:09:09+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T08:09:09+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T08:09:10+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T08:09:10+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.35s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int * None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int * None = None):

                                      ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T07:06:50+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T07:06:50+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T07:06:51+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T07:06:51+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.71s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes * bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031437387921Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031438363068Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.22s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int * None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int * None = None):

                                    ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T20:59:00+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T20:59:00+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T20:59:01+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T20:59:01+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.43s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int / None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int / None = None):

                                   ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T05:03:11+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T05:03:11+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T05:03:12+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T05:03:12+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.26s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int / None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int / None = None):

                                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T17:10:49+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T17:10:49+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T17:10:50+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T17:10:50+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.22s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int / None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int / None = None):

                                     ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T20:15:41+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T20:15:41+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T20:15:42+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T20:15:42+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.56s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int / None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int / None = None):

                                      ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T08:14:41+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T08:14:41+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T08:14:42+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T08:14:43+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.59s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes / bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for /: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.09s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int / None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int / None = None):

                                    ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T19:03:29+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:03:29+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T19:03:30+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:03:30+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.22s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int // None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int // None = None):

                                   ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T18:38:18+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:38:18+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T18:38:19+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:38:19+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.15s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int // None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int // None = None):

                                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T16:31:13+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T16:31:13+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T16:31:14+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T16:31:14+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.32s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int // None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int // None = None):

                                     ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T01:18:00+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T01:18:00+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Network softsec-tatou_default  Removed

time="2025-10-17T01:18:01+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T01:18:01+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.10s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int // None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int // None = None):

                                      ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T18:50:35+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:50:35+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T18:50:36+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:50:36+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.11s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes // bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for //: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 19.83s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int // None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int // None = None):

                                    ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T18:01:03+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:01:03+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T18:01:04+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:01:04+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.21s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int % None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int % None = None):

                                   ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T17:55:40+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T17:55:40+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T17:55:41+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T17:55:41+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.12s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int % None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int % None = None):

                                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T19:54:04+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:54:04+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T19:54:05+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:54:05+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.24s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int % None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int % None = None):

                                     ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T01:55:47+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T01:55:47+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T01:55:48+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T01:55:48+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.18s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int % None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int % None = None):

                                      ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T16:54:44+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T16:54:44+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T16:54:45+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T16:54:45+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.22s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes % bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for %: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.57s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int % None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int % None = None):

                                    ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T06:19:23+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T06:19:23+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T06:19:24+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T06:19:24+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 14.51s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int ** None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int ** None = None):

                                   ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T23:30:34+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T23:30:34+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T23:30:35+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T23:30:35+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.11s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int ** None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int ** None = None):

                                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T19:10:27+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:10:28+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T19:10:29+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:10:29+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.19s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int ** None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int ** None = None):

                                     ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T16:54:09+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T16:54:09+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T16:54:10+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T16:54:10+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.16s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int ** None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int ** None = None):

                                      ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T21:09:37+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T21:09:37+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T21:09:38+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T21:09:38+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.38s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes ** bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ** or pow(): 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.17s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int ** None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int ** None = None):

                                    ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T03:16:41+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:16:41+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T03:16:42+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:16:42+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.34s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int >> None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int >> None = None):

                                   ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T20:54:28+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T20:54:28+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T20:54:29+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T20:54:29+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.46s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int >> None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int >> None = None):

                                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T04:18:22+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T04:18:22+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T04:18:23+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T04:18:23+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.12s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int >> None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int >> None = None):

                                     ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T01:36:28+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T01:36:29+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T01:36:29+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T01:36:30+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.10s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int >> None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int >> None = None):

                                      ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T06:48:03+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T06:48:03+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T06:48:04+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T06:48:04+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.55s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes >> bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for >>: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.23s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int >> None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int >> None = None):

                                    ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T17:30:13+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T17:30:13+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T17:30:14+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T17:30:14+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.03s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int << None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int << None = None):

                                   ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T19:33:52+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:33:52+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T19:33:53+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:33:53+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.20s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int << None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int << None = None):

                                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T23:17:06+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T23:17:06+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T23:17:07+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T23:17:07+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.23s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int << None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int << None = None):

                                     ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T03:35:51+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:35:51+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T03:35:52+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:35:52+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.12s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int << None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int << None = None):

                                      ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T22:54:59+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T22:54:59+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T22:55:00+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T22:55:00+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.56s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes << bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for <<: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.43s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int << None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int << None = None):

                                    ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T17:41:25+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T17:41:25+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T17:41:26+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T17:41:26+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.34s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int & None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int & None = None):

                                   ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T19:15:51+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:15:51+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T19:15:52+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:15:52+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.21s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int & None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int & None = None):

                                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T02:07:56+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T02:07:56+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T02:07:57+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T02:07:57+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.23s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int & None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int & None = None):

                                     ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T23:37:07+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T23:37:07+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T23:37:08+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T23:37:08+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.11s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int & None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int & None = None):

                                      ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T18:27:04+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:27:04+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T18:27:05+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:27:05+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.05s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes & bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for &: 'type' and 'type'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ed0ea412b9753ff31: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.67s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int & None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int & None = None):

                                    ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T18:08:34+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:08:34+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T18:08:35+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:08:35+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.44s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int ^ None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int ^ None = None):

                                   ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T06:18:23+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T06:18:23+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T06:18:24+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T06:18:24+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.67s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int ^ None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int ^ None = None):

                                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T07:00:47+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T07:00:47+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T07:00:48+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T07:00:48+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.48s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int ^ None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int ^ None = None):

                                     ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T18:20:39+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:20:39+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T18:20:40+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:20:40+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.22s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int ^ None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int ^ None = None):

                                      ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T02:35:48+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T02:35:48+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T02:35:49+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T02:35:49+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.25s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes ^ bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ^: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.04s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int ^ None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int ^ None = None):

                                    ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T05:44:58+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T05:44:58+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T05:44:59+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T05:44:59+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.53s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file or file.filename != "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.68s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) != 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T032746344828Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T032747303260Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.79s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if __name__ != "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
timeout
operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file or file.filename < "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T044124269932Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T044125253079Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.34s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) < 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.85s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if __name__ < "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.78s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file or file.filename <= "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053212478833Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053213376746Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.01s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) <= 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if __name__ <= "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.00s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file or file.filename > "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.13s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) > 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 44 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1026 Watermarking produced no output for document 1 using method robust-xmp

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e09d8a933f38ed316: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 23.30s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if __name__ > "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
timeout
operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file or file.filename >= "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.20s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) >= 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 44 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1026 Watermarking produced no output for document 1 using method robust-xmp

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.04s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if __name__ >= "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
timeout
operator: core/ReplaceComparisonOperator_Eq_Is, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file or file.filename is "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:307

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:307: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?

    if not file or file.filename is "":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 23 warnings in 20.59s

operator: core/ReplaceComparisonOperator_Eq_Is, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if __name__ is "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:1264

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:1264: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?

    if __name__ is "__main__":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 23 warnings in 20.19s

operator: core/ReplaceComparisonOperator_Eq_IsNot, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file or file.filename is not "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:307

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:307: SyntaxWarning: "is not" with 'str' literal. Did you mean "!="?

    if not file or file.filename is not "":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 23 warnings in 20.46s

operator: core/ReplaceComparisonOperator_Eq_IsNot, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if __name__ is not "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
timeout
operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if file.mimetype == "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 415 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 415 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.15s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if head == b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
.......F......                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:645 Invalid PDF signature for document id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 13 passed, 22 warnings in 20.49s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if header == b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.11s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if provided == token_required:
             return False
         return True
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T163017353300Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T163018342302Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.38s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if file.mimetype < "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.68s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if head < b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
...F.....FFF.F                                                           [100%]
operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if header < b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if provided < token_required:
             return False
         return True
 
...F.....F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614edf1bed9c7642c6a3: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 21.98s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if file.mimetype <= "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 415 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 415 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 20.34s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if head <= b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T023026311134Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T023027235496Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.23s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if header <= b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
...F.....FFF.F                                                           [100%]
operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if provided <= token_required:
             return False
         return True
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T160233146981Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T160233988525Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.27s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if file.mimetype > "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.39s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if head > b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.36s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if header > b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T165623693620Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T165624670137Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.10s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if provided > token_required:
             return False
         return True
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201051140315Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201052038863Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.58s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if file.mimetype >= "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 415 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 415 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 20.27s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if head >= b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T140631892255Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T140632966795Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.94s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if header >= b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if provided >= token_required:
             return False
         return True
 
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055613210839Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055614185137Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.46s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if file.mimetype is "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:320

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:320: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?

    if file.mimetype is "application/pdf":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 23 warnings in 21.59s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if head is b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:643

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:643: SyntaxWarning: "is" with 'bytes' literal. Did you mean "=="?

    if head is b"%PDF-":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 23 warnings in 20.46s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if header is b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T190055645171Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T190056600511Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:737

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:737: SyntaxWarning: "is" with 'bytes' literal. Did you mean "=="?

    if header is b"%PDF-":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 23 warnings in 19.94s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if provided is token_required:
             return False
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.55s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if file.mimetype is not "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:320

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:320: SyntaxWarning: "is not" with 'str' literal. Did you mean "!="?

    if file.mimetype is not "application/pdf":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 415 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 415 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 23 warnings in 19.72s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if head is not b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
.......F......                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:645 Invalid PDF signature for document id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:643

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:643: SyntaxWarning: "is not" with 'bytes' literal. Did you mean "!="?

    if head is not b"%PDF-":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 13 passed, 23 warnings in 20.14s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if header is not b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001443515834Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001444386192Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:737

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:737: SyntaxWarning: "is not" with 'bytes' literal. Did you mean "!="?

    if header is not b"%PDF-":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 23 warnings in 19.46s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if provided is not token_required:
             return False
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.04s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id == 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id == 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e75239795debe531e: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.67s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id == 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.41s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id == 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.36s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id == 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.08s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id == 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.22s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id != 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T192458760453Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T192459772862Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.15s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id != 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002611761725Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002612661673Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.29s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id != 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.......F...F..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:446: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 12 passed, 22 warnings in 21.25s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id != 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 21.82s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id != 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef560a9e411a7ac9a: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.59s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id != 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.93s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id < 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.94s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id < 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.82s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id < 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 20.05s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id < 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.32s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id < 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.29s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id < 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id > 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.26s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id > 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.68s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id > 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
...F...F.FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1c77a67b355a20eb: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

6 failed, 8 passed, 22 warnings in 19.58s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id > 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.13s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id > 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.20s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id > 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 25.00s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id >= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.55s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id >= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.44s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id >= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.......F...F..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:446: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 12 passed, 22 warnings in 20.62s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id >= 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T174457659566Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T174458670562Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

10 failed, 4 passed, 22 warnings in 20.03s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id >= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171156392900Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171157236434Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.21s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id >= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.33s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) == 320 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 or len(login) == 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length and file.content_length == MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
...F......F...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 201 == 413

E            +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:181: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

>           assert upload_resp_data.get("id") == 2

E           AssertionError: assert 3 == 2

E            +  where 3 = <built-in method get of dict object at 0x0000021FCA9A2200>('id')

E            +    where <built-in method get of dict object at 0x0000021FCA9A2200> = {'creation': '2025-10-17T03:06:18.113591', 'id': 3, 'name': 'Water File', 'sha256': '5FBAC867F5EFDD7B0AB5C11456B204DDD08FF8801502C93728BE3B38BFAFE80C', ...}.get



..\test\test_api.py:390: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 201 == 413

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

2 failed, 12 passed, 22 warnings in 21.17s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 or document_id == MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id == MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.31s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id == MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 or doc_id == MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.38s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id == MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id == MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T173324928655Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T173325815091Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.39s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) != 320 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 36 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054608604502Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054609592062Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 20.06s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 or len(login) != 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 36 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011951430007Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011952394652Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.33s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length and file.content_length != MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201515853583Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201516867232Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.83s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 or document_id != MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.22s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id != MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.11s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id != MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.......F...F..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:446: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 12 passed, 22 warnings in 20.75s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 or doc_id != MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.54s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id != MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T141303446643Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T141304402767Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.48s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id != MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 19.84s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) < 320 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 36 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171055236960Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171056101636Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.20s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 or len(login) < 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 36 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T224351145014Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T224352146478Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 20.57s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length and file.content_length < MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T182002688318Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T182003602131Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.58s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 or document_id < MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055208370591Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055209315930Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.51s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id < MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.42s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id < MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T040937953006Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T040938869428Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.61s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 or doc_id < MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151427778917Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151428654805Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

9 failed, 5 passed, 22 warnings in 19.21s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id < MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.17s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id < MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 19.82s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) <= 320 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 36 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T014237306969Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T014238257949Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.01s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 or len(login) <= 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFFFF.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 36 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T213027381126Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T213028227862Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

10 failed, 4 passed, 22 warnings in 19.13s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length and file.content_length <= MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
...F......F...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 201 == 413

E            +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:181: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

>           assert upload_resp_data.get("id") == 2

E           AssertionError: assert 3 == 2

E            +  where 3 = <built-in method get of dict object at 0x00000228BD07AA40>('id')

E            +    where <built-in method get of dict object at 0x00000228BD07AA40> = {'creation': '2025-10-16T15:25:16.167040', 'id': 3, 'name': 'Water File', 'sha256': '5FBAC867F5EFDD7B0AB5C11456B204DDD08FF8801502C93728BE3B38BFAFE80C', ...}.get



..\test\test_api.py:390: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 201 == 413

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

2 failed, 12 passed, 22 warnings in 20.08s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 or document_id <= MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.67s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id <= MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 25.94s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id <= MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025619735026Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025620654636Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.94s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 or doc_id <= MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 22.08s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id <= MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.69s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id <= MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.18s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) >= 320 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.17s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 or len(login) >= 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length and file.content_length >= MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.03s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 or document_id >= MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.31s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id >= MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id >= MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.82s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 or doc_id >= MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193230227375Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193231161127Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.83s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id >= MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id >= MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.17s

operator: core/ReplaceComparisonOperator_Gt_Is, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length and file.content_length is MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e518cc3a4126099e0: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.67s

operator: core/ReplaceComparisonOperator_Gt_Is, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 or document_id is MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceComparisonOperator_Gt_Is, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id is MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T200905857818Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T200906698201Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.34s

operator: core/ReplaceComparisonOperator_Gt_Is, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id is MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T170219356069Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T170220197173Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.04s

operator: core/ReplaceComparisonOperator_Gt_Is, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 or doc_id is MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceComparisonOperator_Gt_Is, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id is MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/ReplaceComparisonOperator_Gt_Is, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id is MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
...F.....FFF.F                                                           [100%]
operator: core/ReplaceComparisonOperator_Gt_IsNot, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length and file.content_length is not MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/ReplaceComparisonOperator_Gt_IsNot, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 or document_id is not MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T234217208412Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T234218092185Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.15s

operator: core/ReplaceComparisonOperator_Gt_IsNot, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id is not MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.64s

operator: core/ReplaceComparisonOperator_Gt_IsNot, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id is not MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.......F...F..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:446: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 12 passed, 22 warnings in 20.38s

operator: core/ReplaceComparisonOperator_Gt_IsNot, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 or doc_id is not MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010746974726Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010747902391Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

9 failed, 5 passed, 22 warnings in 19.33s

operator: core/ReplaceComparisonOperator_Gt_IsNot, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id is not MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 19.84s

operator: core/ReplaceComparisonOperator_Gt_IsNot, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id is not MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.34s

operator: core/ReplaceComparisonOperator_Is_Eq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable == False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.54s

operator: core/ReplaceComparisonOperator_Is_NotEq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable != False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155432007173Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155432945141Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.35s

operator: core/ReplaceComparisonOperator_Is_Lt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable < False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/ReplaceComparisonOperator_Is_LtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable <= False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 22.88s

operator: core/ReplaceComparisonOperator_Is_Gt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable > False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.09s

operator: core/ReplaceComparisonOperator_Is_GtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable >= False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 21.03s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -71,7 +71,7 @@
 
     def get_engine():
         eng = app.config.get("_ENGINE")
-        if eng is None:
+        if eng is not None:
             try:
                 eng = create_engine(db_url(), pool_pre_ping=True, future=True)
             except Exception as e:
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: 'NoneType' object has no attribute 'begin'

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: 'NoneType' object has no attribute 'connect'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T205627757971Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document 'NoneType' object has no attribute 'connect'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T205628593543Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: 'NoneType' object has no attribute 'connect'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: 'NoneType' object has no attribute 'begin'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 20.02s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -455,7 +455,7 @@
     @require_auth
     def list_versions(document_id: int | None = None):
         # Input validation
-        if document_id is None:
+        if document_id is not None:
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231059643741Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231100530798Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.32s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is not None or document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.55s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is not None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
...F.F...FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eb48e2b64635ab109: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

6 failed, 8 passed, 22 warnings in 19.59s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -572,7 +572,7 @@
     @require_auth
     def get_document(document_id: int | None = None):
         # Support both path param and ?id=/ ?documentid=
-        if document_id is None:
+        if document_id is not None:
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id)
.......F...F..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:446: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 12 passed, 22 warnings in 20.36s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is not None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.......F...F..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:446: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 12 passed, 22 warnings in 22.27s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -810,7 +810,7 @@
                 or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
 
-        if document_id is None:
+        if document_id is not None:
             app.logger.warning("Document id required for deletion")
             return jsonify({"error": "document id required"}), 400
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T030904307583Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T030905285580Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:814 Document id required for deletion

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

8 failed, 6 passed, 22 warnings in 19.38s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -930,7 +930,7 @@
 
         # validate input
         try:
-            if doc_id is None:
+            if doc_id is not None:
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:934 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 19.84s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable is not False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.08s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1165,7 +1165,7 @@
 
         # validate input
         try:
-            if doc_id is None:
+            if doc_id is not None:
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.45s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -81,7 +81,7 @@
         return eng
 
     # --- RMAP initialization (skippable in tests) ---
-    if RMAPHandler is not None:
+    if RMAPHandler is None:
         try:
             RMAPHandler(app, str(app.config["STORAGE_DIR"]), get_engine)
         except Exception as e:  # pragma: no cover - defensive; don't fail app
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.46s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -141,7 +141,7 @@
             # capture request size if content-length header present
             try:
                 cl = request.content_length
-                if cl is not None:
+                if cl is None:
                     observe_request_size(request.method, route, cl)
             except Exception as exc:  # pragma: no cover - soft fail
                 app.logger.warning("Request size capture failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.88s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -152,7 +152,7 @@
     def _tatou_after(resp):
         try:
             start = getattr(request, "_tatou_start", None)
-            if start is not None:
+            if start is None:
                 dur = time.time() - start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053635599166Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053636431274Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.22s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -34,7 +34,7 @@
 MAX_DB_INT = (2**63) - 1
 
 RMAPHandler = None  # default
-if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
+if  os.environ.get("TATOU_TEST_DISABLE_RMAP"):
     try:  # Allow tests to disable RMAP dependency via env var
         from rmap_handler import RMAPHandler as _RMAPHandler  # type: ignore
 
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001524330438Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001524567484Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.87s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -102,7 +102,7 @@
                 g.user = {"id": 1, "login": "username", "email": "user@email.se"}
                 return f(*args, **kwargs)
             auth = request.headers.get("Authorization", "")
-            if not auth.startswith("Bearer "):
+            if  auth.startswith("Bearer "):
                 return _auth_error("Missing or invalid Authorization header")
             token = auth.split(" ", 1)[1].strip()
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -187,7 +187,7 @@
         """Validate user input before database operations"""
         if len(email) > 320 or len(login) > 64:
             return False, "Email or login too long"
-        if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
+        if  re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
         if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
             return False, "Invalid login format"
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid email format

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T004351080357Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T004351938886Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid email format

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.12s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -189,7 +189,7 @@
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
-        if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
+        if  re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
             return False, "Invalid login format"
         return True, ""
 
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid login format

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155645323724Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155646216694Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid login format

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.24s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -201,7 +201,7 @@
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
-        if not email or not login or not password:
+        if  email or not login or not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
             return jsonify({"error": "email, login, and password are required"}), 400
 
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username', 'password': 'password'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011356133882Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011357055022Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'service@rmap.su', 'login': 'rmap_service', 'password': 'password_rmap'}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.22s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -201,7 +201,7 @@
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
-        if not email or not login or not password:
+        if not email or  login or not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
             return jsonify({"error": "email, login, and password are required"}), 400
 
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username', 'password': 'password'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T040855163564Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T040856096583Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'service@rmap.su', 'login': 'rmap_service', 'password': 'password_rmap'}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.91s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -201,7 +201,7 @@
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
-        if not email or not login or not password:
+        if not email or not login or  password:
             app.logger.warning("Missing fields in user creation: %s", payload)
             return jsonify({"error": "email, login, and password are required"}), 400
 
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username', 'password': 'password'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T000310706490Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T000311658266Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'service@rmap.su', 'login': 'rmap_service', 'password': 'password_rmap'}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.19s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -209,7 +209,7 @@
 
         try:
             is_valid, error_msg = validate_user_input(email, login)
-            if not is_valid:
+            if  is_valid:
                 app.logger.warning("User input validation failed: %s", error_msg)
                 return jsonify({"error": error_msg}), 400
 
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 13 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed:

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T040643012341Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T040643997675Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: 

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 20.46s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -245,7 +245,7 @@
         email = (payload.get("email") or "").strip()
         password = payload.get("password") or ""
 
-        if not email or not password:
+        if  email or not password:
             app.logger.warning("Missing fields in login attempt: %s", payload)
             return jsonify({"error": "email and password are required"}), 400
 
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 44 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'email': 'user@email.se', 'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.78s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -245,7 +245,7 @@
         email = (payload.get("email") or "").strip()
         password = payload.get("password") or ""
 
-        if not email or not password:
+        if not email or  password:
             app.logger.warning("Missing fields in login attempt: %s", payload)
             return jsonify({"error": "email and password are required"}), 400
 
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 44 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'email': 'user@email.se', 'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.53s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -268,7 +268,7 @@
                     is_valid = False
                     row = None
 
-                if not is_valid:
+                if  is_valid:
                     app.logger.warning(
                         "Failed login attempt for email: %s",
                         email if email else "<empty>",
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

1 failed, 13 passed, 22 warnings in 20.34s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if  file or file.filename == "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.33s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -323,7 +323,7 @@
                 "Upload attempt with invalid MIME type: %s", file.mimetype
             )
             return jsonify({"error": "only PDF files are allowed"}), 415
-        if not file.filename.lower().endswith(".pdf"):
+        if  file.filename.lower().endswith(".pdf"):
             inc_suspicious("upload_bad_extension")
             app.logger.warning(
                 "Upload attempt with invalid file extension: %s", file.filename
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:328 Upload attempt with invalid file extension: input.pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:328 Upload attempt with invalid file extension: watermarked.pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 415 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 415 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.22s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 13
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -332,7 +332,7 @@
 
         # Sanitize filename
         fname = secure_filename(file.filename)
-        if not fname:
+        if  fname:
             app.logger.warning(
                 "Upload attempt with invalid filename: %s", file.filename
             )
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 29 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:336 Upload attempt with invalid filename: input.pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 29 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:336 Upload attempt with invalid filename: watermarked.pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.53s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 14
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -348,7 +348,7 @@
         try:
             # Check for path traversal attempts
             stored_path = (user_dir / stored_name).resolve()
-            if not str(stored_path).startswith(str(user_dir.resolve())):
+            if  str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 25 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:352 Upload attempt with invalid path: C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223419230146Z__input.pdf

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 25 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:352 Upload attempt with invalid path: C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223420067525Z__watermarked.pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.60s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 15
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -482,7 +482,7 @@
                     {"did": document_id, "uid": int(g.user["id"])},
                 ).first()
 
-                if not doc:
+                if  doc:
                     app.logger.warning(
                         "Document not found or access denied for id=%s", document_id
                     )
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

1 failed, 13 passed, 22 warnings in 21.37s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 16
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -526,7 +526,7 @@
     def list_all_versions():
         try:
             # Validate user data from auth token
-            if not g.user or not g.user.get("id"):
+            if  g.user or not g.user.get("id"):
                 app.logger.error("Missing user info in auth token")
                 return jsonify({"error": "Invalid authentication"}), 401
 
......F.......                                                           [100%]

================================== FAILURES ===================================

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 35 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:530 Missing user info in auth token

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 401 == 200

1 failed, 13 passed, 22 warnings in 20.48s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 17
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -526,7 +526,7 @@
     def list_all_versions():
         try:
             # Validate user data from auth token
-            if not g.user or not g.user.get("id"):
+            if not g.user or  g.user.get("id"):
                 app.logger.error("Missing user info in auth token")
                 return jsonify({"error": "Invalid authentication"}), 401
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T051957337814Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 35 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:530 Missing user info in auth token

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T051958402354Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 401 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 21.05s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 18
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -606,7 +606,7 @@
             ), 503
 
         # DonÔÇÖt leak whether a doc exists for another user
-        if not row:
+        if  row:
             app.logger.warning(
                 "Document not found or access denied for id=%s", document_id
             )
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T044252127444Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

>       resp = client.get("/api/get-document", query_string=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:273: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.get("/api/get-document")

    @app.get("/api/get-document/<int:document_id>")

    @require_auth

    def get_document(document_id: int | None = None):

        # Support both path param and ?id=/ ?documentid=

        if document_id is None:

            document_id = request.args.get("id") or request.args.get("documentid")

            try:

                document_id = int(document_id)

            except (TypeError, ValueError):

                app.logger.warning("Invalid document id in query")

                return jsonify({"error": "document id required"}), 400

    

        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:

            return jsonify({"error": "document id required"}), 400

    

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id AND ownerid = :uid

                        LIMIT 1

                    """

                    ),

                    {"id": document_id, "uid": int(g.user["id"])},

                ).first()

        except Exception:

            app.logger.error(

                f"Database error in get_document: {document_id},{g.user['id']}"

            )

            inc_db_error("get_document")

            return jsonify(

                {"error": "An error occurred while fetching the document"}

            ), 503

    

        # DonÔÇÖt leak whether a doc exists for another user

        if  row:

            app.logger.warning(

                "Document not found or access denied for id=%s", document_id

            )

            return jsonify({"error": "document not found"}), 404

    

        storage_root = app.config["STORAGE_DIR"].resolve()

>       file_path = Path(row.path)

                         ^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'path'



server.py:616: AttributeError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T044253148301Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - AttributeError: 'NoneTy...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.69s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 19
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -626,7 +626,7 @@
             )
             return jsonify({"error": "document path invalid"}), 500
 
-        if not resolved.exists():
+        if  resolved.exists():
             app.logger.error("File missing on disk for document id=%s", document_id)
             return jsonify({"error": "file missing on disk"}), 410
 
...F...F......                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:630 File missing on disk for document id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_get_document_route - assert False

2 failed, 12 passed, 22 warnings in 21.61s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 20
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -651,7 +651,7 @@
 
             # Prepare safe filename (preserve existing .pdf if present)
             name = (row.name or "document").strip().replace("\r", "").replace("\n", "")
-            if not name.lower().endswith(".pdf"):
+            if  name.lower().endswith(".pdf"):
                 name = f"{name}.pdf"
 
             # Stat via the same FD to avoid TOCTOU
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 21
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -693,7 +693,7 @@
     @app.get("/api/get-version/<link>")
     def get_version(link: str):
         # Accept both 32-char (RMAP session secrets) and 64-char (SHA-256 style) tokens
-        if not re.fullmatch(r"[0-9a-f]{32}|[0-9a-f]{64}", link):
+        if  re.fullmatch(r"[0-9a-f]{32}|[0-9a-f]{64}", link):
             app.logger.warning("Invalid version link format: %s", link)
             return jsonify({"error": "document not found"}), 404
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 22
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -715,7 +715,7 @@
             inc_db_error("get_version")
             return jsonify({"error": "database error"}), 503
 
-        if not row:
+        if  row:
             app.logger.warning("Version not found for link: %s", link)
             return jsonify({"error": "document not found"}), 404
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.27s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 23
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -727,7 +727,7 @@
             )
             return jsonify({"error": "document path invalid"}), 500
 
-        if not resolved.exists():
+        if  resolved.exists():
             app.logger.error("File missing on disk for version link=%s", link)
             return jsonify({"error": "file missing on disk"}), 410
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.97s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 24
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -781,7 +781,7 @@
     def _safe_resolve_under_storage(p: str, storage_root: Path) -> Path:
         storage_root = storage_root.resolve()
         fp = Path(p)
-        if not fp.is_absolute():
+        if  fp.is_absolute():
             fp = storage_root / fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.80s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 25
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -786,7 +786,7 @@
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
-            if not fp.is_relative_to(storage_root):
+            if  fp.is_relative_to(storage_root):
                 raise RuntimeError(f"path {fp} escapes storage root {storage_root}")
         else:
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.98s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 26
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -845,7 +845,7 @@
             inc_db_error("delete_document_select")
             return jsonify({"error": "database error during delete"}), 503
 
-        if not row:
+        if  row:
             # DonÔÇÖt reveal othersÔÇÖ docsÔÇöjust say not found
             app.logger.warning(
                 "Document not found or access denied for deletion id=%s", doc_id
...........F..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

1 failed, 13 passed, 22 warnings in 21.65s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 27
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -908,7 +908,7 @@
     @require_auth
     def create_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
-        if not document_id:
+        if  document_id:
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:934 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.73s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 28
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -940,7 +940,7 @@
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
         if (
-            not method
+             method
             or not intended_for
             or not isinstance(secret, str)
             or not isinstance(key, str)
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 63 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'method': 'robust-xmp', 'position': 'metadata-only', 'secret': 'secret'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 19.90s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 29
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -941,7 +941,7 @@
             return jsonify({"error": "document_id (int) is required"}), 400
         if (
             not method
-            or not intended_for
+            or  intended_for
             or not isinstance(secret, str)
             or not isinstance(key, str)
         ):
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 63 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'method': 'robust-xmp', 'position': 'metadata-only', 'secret': 'secret'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.35s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 30
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -942,7 +942,7 @@
         if (
             not method
             or not intended_for
-            or not isinstance(secret, str)
+            or  isinstance(secret, str)
             or not isinstance(key, str)
         ):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 63 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'method': 'robust-xmp', 'position': 'metadata-only', 'secret': 'secret'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.14s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 31
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -943,7 +943,7 @@
             not method
             or not intended_for
             or not isinstance(secret, str)
-            or not isinstance(key, str)
+            or  isinstance(key, str)
         ):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify(
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 63 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'method': 'robust-xmp', 'position': 'metadata-only', 'secret': 'secret'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.45s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 32
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -968,7 +968,7 @@
             app.logger.error("Database error fetching document %s", e)
             return jsonify({"error": "database error"}), 503
 
-        if not row:
+        if  row:
             app.logger.warning(
                 "Document not found or access denied for watermarking id=%s", doc_id
             )
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

1 failed, 13 passed, 22 warnings in 20.15s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 33
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -977,7 +977,7 @@
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
-        if not file_path.is_absolute():
+        if  file_path.is_absolute():
             file_path = storage_root / file_path
         file_path = file_path.resolve()
         try:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020609195823Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020610124068Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.31s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 34
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -985,7 +985,7 @@
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
             return jsonify({"error": "document path invalid"}), 500
-        if not file_path.exists():
+        if  file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
 
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 410 == 201

E        +  where 410 = <WrapperTestResponse 33 bytes [410 GONE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:989 File missing on disk for document id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 410 == 201

1 failed, 13 passed, 22 warnings in 20.30s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 35
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if  isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
...F.....FFF.F                                                           [100%]
operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 36
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1145,7 +1145,7 @@
     @require_auth
     def read_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
-        if not document_id:
+        if  document_id:
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.42s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 37
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1174,7 +1174,7 @@
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
-        if not method or not isinstance(method, str) or not isinstance(key, str):
+        if  method or not isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
 
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 41 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1178 Missing required fields for watermarking: {'id': 2, 'key': 'strong-password', 'method': 'overlay-watermark', 'position': 'metadata-only'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 19.83s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 38
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1174,7 +1174,7 @@
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
-        if not method or not isinstance(method, str) or not isinstance(key, str):
+        if not method or  isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1bfc99941133eec5: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.77s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 39
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1174,7 +1174,7 @@
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
-        if not method or not isinstance(method, str) or not isinstance(key, str):
+        if not method or not isinstance(method, str) or  isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
 
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 41 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1178 Missing required fields for watermarking: {'id': 2, 'key': 'strong-password', 'method': 'overlay-watermark', 'position': 'metadata-only'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 19.79s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 40
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1198,7 +1198,7 @@
             )
             return jsonify({"error": "database error"}), 503
 
-        if not row:
+        if  row:
             app.logger.warning(
                 "Document not found or access denied for watermark read id=%s", doc_id
             )
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1202 Document not found or access denied for watermark read id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 404 == 201

1 failed, 13 passed, 22 warnings in 20.04s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 41
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1207,7 +1207,7 @@
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
-        if not file_path.is_absolute():
+        if  file_path.is_absolute():
             file_path = storage_root / file_path
         file_path = file_path.resolve()
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.53s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 42
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1215,7 +1215,7 @@
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
             return jsonify({"error": "document path invalid"}), 500
-        if not file_path.exists():
+        if  file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
 
...F.....FFF.F                                                           [100%]
operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 43
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1246,7 +1246,7 @@
 
     @app.get("/metrics")
     def metrics():
-        if not _is_authorized_metrics_request():
+        if  _is_authorized_metrics_request():
             # Obscure existence a bit ÔÇô return 404 instead of 403 to casual scans
             app.logger.warning(
                 "Unauthorized metrics access attempt from %s", request.remote_addr
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.06s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -34,7 +34,7 @@
 MAX_DB_INT = (2**63) - 1
 
 RMAPHandler = None  # default
-if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
+if not not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
     try:  # Allow tests to disable RMAP dependency via env var
         from rmap_handler import RMAPHandler as _RMAPHandler  # type: ignore
 
.FFFFF.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031721917928Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031722251569Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

11 failed, 3 passed, 9 warnings in 13.99s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -71,7 +71,7 @@
 
     def get_engine():
         eng = app.config.get("_ENGINE")
-        if eng is None:
+        if not eng is None:
             try:
                 eng = create_engine(db_url(), pool_pre_ping=True, future=True)
             except Exception as e:
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: 'NoneType' object has no attribute 'begin'

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: 'NoneType' object has no attribute 'connect'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223358858725Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document 'NoneType' object has no attribute 'connect'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223359585742Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: 'NoneType' object has no attribute 'connect'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: 'NoneType' object has no attribute 'begin'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.16s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -81,7 +81,7 @@
         return eng
 
     # --- RMAP initialization (skippable in tests) ---
-    if RMAPHandler is not None:
+    if not RMAPHandler is not None:
         try:
             RMAPHandler(app, str(app.config["STORAGE_DIR"]), get_engine)
         except Exception as e:  # pragma: no cover - defensive; don't fail app
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T200023741880Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T200023966265Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.81s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -98,7 +98,7 @@
     def require_auth(f):
         @wraps(f)
         def wrapper(*args, **kwargs):
-            if app.config['TESTING']:
+            if not app.config['TESTING']:
                 g.user = {"id": 1, "login": "username", "email": "user@email.se"}
                 return f(*args, **kwargs)
             auth = request.headers.get("Authorization", "")
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 401 == 201

E            +  where 401 = <WrapperTestResponse 52 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 52 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 52 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 52 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 401 == 201

E        +  where 401 = <WrapperTestResponse 52 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 401 == 201

E            +  where 401 = <WrapperTestResponse 52 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 401 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 401 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 401 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 401 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 401 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 401 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 401 == 200

10 failed, 4 passed, 22 warnings in 19.11s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -102,7 +102,7 @@
                 g.user = {"id": 1, "login": "username", "email": "user@email.se"}
                 return f(*args, **kwargs)
             auth = request.headers.get("Authorization", "")
-            if not auth.startswith("Bearer "):
+            if not not auth.startswith("Bearer "):
                 return _auth_error("Missing or invalid Authorization header")
             token = auth.split(" ", 1)[1].strip()
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.84s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -136,7 +136,7 @@
     def _tatou_before():
         try:  # record start for latency
             request._tatou_start = time.time()  # type: ignore[attr-defined]
-            route = request.url_rule.rule if request.url_rule else request.path
+            route = request.url_rule.rule if not request.url_rule else request.path
             inc_inflight(route)
             # capture request size if content-length header present
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/AddNot, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -141,7 +141,7 @@
             # capture request size if content-length header present
             try:
                 cl = request.content_length
-                if cl is not None:
+                if not cl is not None:
                     observe_request_size(request.method, route, cl)
             except Exception as exc:  # pragma: no cover - soft fail
                 app.logger.warning("Request size capture failed: %s", exc)
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T211426149062Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T211427309130Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 21.74s

operator: core/AddNot, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -152,7 +152,7 @@
     def _tatou_after(resp):
         try:
             start = getattr(request, "_tatou_start", None)
-            if start is not None:
+            if not start is not None:
                 dur = time.time() - start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035148053628Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035148971652Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.39s

operator: core/AddNot, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -154,7 +154,7 @@
             start = getattr(request, "_tatou_start", None)
             if start is not None:
                 dur = time.time() - start
-                route = request.url_rule.rule if request.url_rule else request.path
+                route = request.url_rule.rule if not request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
             app.logger.warning("after_request instrumentation failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.34s

operator: core/AddNot, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if not len(email) > 320 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 36 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T043327436610Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T043328453761Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.86s

operator: core/AddNot, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -187,7 +187,7 @@
         """Validate user input before database operations"""
         if len(email) > 320 or len(login) > 64:
             return False, "Email or login too long"
-        if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
+        if not not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
         if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
             return False, "Invalid login format"
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid email format

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T145554121275Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T145555020738Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid email format

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.14s

operator: core/AddNot, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -189,7 +189,7 @@
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
-        if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
+        if not not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
             return False, "Invalid login format"
         return True, ""
 
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid login format

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T213617036713Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T213618095161Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid login format

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 20.56s

operator: core/AddNot, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -201,7 +201,7 @@
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
-        if not email or not login or not password:
+        if not not email or not login or not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
             return jsonify({"error": "email, login, and password are required"}), 400
 
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username', 'password': 'password'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T232032699243Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T232033674852Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'service@rmap.su', 'login': 'rmap_service', 'password': 'password_rmap'}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 18.95s

operator: core/AddNot, occurrence: 13
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -209,7 +209,7 @@
 
         try:
             is_valid, error_msg = validate_user_input(email, login)
-            if not is_valid:
+            if not not is_valid:
                 app.logger.warning("User input validation failed: %s", error_msg)
                 return jsonify({"error": error_msg}), 400
 
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 13 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed:

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201828485096Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201829396459Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: 

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.55s

operator: core/AddNot, occurrence: 14
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -245,7 +245,7 @@
         email = (payload.get("email") or "").strip()
         password = payload.get("password") or ""
 
-        if not email or not password:
+        if not not email or not password:
             app.logger.warning("Missing fields in login attempt: %s", payload)
             return jsonify({"error": "email and password are required"}), 400
 
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 44 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'email': 'user@email.se', 'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.34s

operator: core/AddNot, occurrence: 15
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -261,7 +261,7 @@
                 ).first()
 
                 # Constant-time comparison to prevent timing attacks
-                if row:
+                if not row:
                     is_valid = check_password_hash(row.hpassword, password)
                 else:
                     # Dummy check to maintain constant time
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

1 failed, 13 passed, 22 warnings in 20.23s

operator: core/AddNot, occurrence: 16
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -268,7 +268,7 @@
                     is_valid = False
                     row = None
 
-                if not is_valid:
+                if not not is_valid:
                     app.logger.warning(
                         "Failed login attempt for email: %s",
                         email if email else "<empty>",
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

1 failed, 13 passed, 22 warnings in 20.41s

operator: core/AddNot, occurrence: 17
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -271,7 +271,7 @@
                 if not is_valid:
                     app.logger.warning(
                         "Failed login attempt for email: %s",
-                        email if email else "<empty>",
+                        email if not email else "<empty>",
                     )
                     inc_login_failure("invalid_credentials")
                     return jsonify({"error": "invalid credentials"}), 401
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/AddNot, occurrence: 18
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -298,7 +298,7 @@
     @app.post("/api/upload-document")
     @require_auth
     def upload_document():
-        if "file" not in request.files:
+        if not "file" not in request.files:
             inc_suspicious("upload_missing_file_field")
             app.logger.warning("Upload attempt missing 'file' field")
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 51 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 51 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 20.04s

operator: core/AddNot, occurrence: 19
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not not file or file.filename == "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.35s

operator: core/AddNot, occurrence: 20
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if not file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 500 == 413

E            +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:181: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 413

1 failed, 13 passed, 22 warnings in 20.57s

operator: core/AddNot, occurrence: 21
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if not file.mimetype != "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 415 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 415 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.09s

operator: core/AddNot, occurrence: 22
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -323,7 +323,7 @@
                 "Upload attempt with invalid MIME type: %s", file.mimetype
             )
             return jsonify({"error": "only PDF files are allowed"}), 415
-        if not file.filename.lower().endswith(".pdf"):
+        if not not file.filename.lower().endswith(".pdf"):
             inc_suspicious("upload_bad_extension")
             app.logger.warning(
                 "Upload attempt with invalid file extension: %s", file.filename
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:328 Upload attempt with invalid file extension: input.pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:328 Upload attempt with invalid file extension: watermarked.pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 415 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 415 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.16s

operator: core/AddNot, occurrence: 23
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -332,7 +332,7 @@
 
         # Sanitize filename
         fname = secure_filename(file.filename)
-        if not fname:
+        if not not fname:
             app.logger.warning(
                 "Upload attempt with invalid filename: %s", file.filename
             )
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 29 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:336 Upload attempt with invalid filename: input.pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 29 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:336 Upload attempt with invalid filename: watermarked.pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.11s

operator: core/AddNot, occurrence: 24
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -348,7 +348,7 @@
         try:
             # Check for path traversal attempts
             stored_path = (user_dir / stored_name).resolve()
-            if not str(stored_path).startswith(str(user_dir.resolve())):
+            if not not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
 
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 25 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:352 Upload attempt with invalid path: C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T192728549425Z__input.pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 25 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:352 Upload attempt with invalid path: C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T192729606749Z__watermarked.pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.57s

operator: core/AddNot, occurrence: 25
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -403,7 +403,7 @@
             "id": int(row.id),
             "name": row.name,
             "creation": row.creation.isoformat()
-            if hasattr(row.creation, "isoformat")
+            if not hasattr(row.creation, "isoformat")
             else str(row.creation),
             "sha256": row.sha256_hex,
             "size": int(row.size),
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.10s

operator: core/AddNot, occurrence: 26
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -440,7 +440,7 @@
                 "id": int(r.id),
                 "name": r.name,
                 "creation": r.creation.isoformat()
-                if hasattr(r.creation, "isoformat")
+                if not hasattr(r.creation, "isoformat")
                 else str(r.creation),
                 "sha256": r.sha256_hex,
                 "size": int(r.size),
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.70s

operator: core/AddNot, occurrence: 27
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -455,7 +455,7 @@
     @require_auth
     def list_versions(document_id: int | None = None):
         # Input validation
-        if document_id is None:
+        if not document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.38s

operator: core/AddNot, occurrence: 28
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -458,7 +458,7 @@
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
-                document_id = int(document_id) if document_id else None
+                document_id = int(document_id) if not document_id else None
                 if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.22s

operator: core/AddNot, occurrence: 29
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if not document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031458563050Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031459517386Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.92s

operator: core/AddNot, occurrence: 30
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if not document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
...F.F...FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e3ada16812490f1bb: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

6 failed, 8 passed, 22 warnings in 21.55s

operator: core/AddNot, occurrence: 31
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -482,7 +482,7 @@
                     {"did": document_id, "uid": int(g.user["id"])},
                 ).first()
 
-                if not doc:
+                if not not doc:
                     app.logger.warning(
                         "Document not found or access denied for id=%s", document_id
                     )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041513367534Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041514725482Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 21.92s

operator: core/AddNot, occurrence: 32
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -526,7 +526,7 @@
     def list_all_versions():
         try:
             # Validate user data from auth token
-            if not g.user or not g.user.get("id"):
+            if not not g.user or not g.user.get("id"):
                 app.logger.error("Missing user info in auth token")
                 return jsonify({"error": "Invalid authentication"}), 401
 
...F..F..FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 35 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:530 Missing user info in auth token

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eceb130736ddb771c: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 401 == 200

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

6 failed, 8 passed, 22 warnings in 23.71s

operator: core/AddNot, occurrence: 33
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -572,7 +572,7 @@
     @require_auth
     def get_document(document_id: int | None = None):
         # Support both path param and ?id=/ ?documentid=
-        if document_id is None:
+        if not document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155452317866Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155453182960Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.38s

operator: core/AddNot, occurrence: 34
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if not document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.......F...F..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:446: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 12 passed, 22 warnings in 20.80s

operator: core/AddNot, occurrence: 35
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -606,7 +606,7 @@
             ), 503
 
         # DonÔÇÖt leak whether a doc exists for another user
-        if not row:
+        if not not row:
             app.logger.warning(
                 "Document not found or access denied for id=%s", document_id
             )
.......F...F..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

>       resp_deletion = client.get("/api/get-document/2")

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:445: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 2



    @app.get("/api/get-document")

    @app.get("/api/get-document/<int:document_id>")

    @require_auth

    def get_document(document_id: int | None = None):

        # Support both path param and ?id=/ ?documentid=

        if document_id is None:

            document_id = request.args.get("id") or request.args.get("documentid")

            try:

                document_id = int(document_id)

            except (TypeError, ValueError):

                app.logger.warning("Invalid document id in query")

                return jsonify({"error": "document id required"}), 400

    

        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:

            return jsonify({"error": "document id required"}), 400

    

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id AND ownerid = :uid

                        LIMIT 1

                    """

                    ),

                    {"id": document_id, "uid": int(g.user["id"])},

                ).first()

        except Exception:

            app.logger.error(

                f"Database error in get_document: {document_id},{g.user['id']}"

            )

            inc_db_error("get_document")

            return jsonify(

                {"error": "An error occurred while fetching the document"}

            ), 503

    

        # DonÔÇÖt leak whether a doc exists for another user

        if not not row:

            app.logger.warning(

                "Document not found or access denied for id=%s", document_id

            )

            return jsonify({"error": "document not found"}), 404

    

        storage_root = app.config["STORAGE_DIR"].resolve()

>       file_path = Path(row.path)

                         ^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'path'



server.py:616: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - AttributeError: 'Non...

2 failed, 12 passed, 22 warnings in 20.38s

operator: core/AddNot, occurrence: 36
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -626,7 +626,7 @@
             )
             return jsonify({"error": "document path invalid"}), 500
 
-        if not resolved.exists():
+        if not not resolved.exists():
             app.logger.error("File missing on disk for document id=%s", document_id)
             return jsonify({"error": "file missing on disk"}), 410
 
.......F......                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:630 File missing on disk for document id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 13 passed, 22 warnings in 20.86s

operator: core/AddNot, occurrence: 37
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if not head != b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
.......F......                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:645 Invalid PDF signature for document id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 13 passed, 22 warnings in 20.47s

operator: core/AddNot, occurrence: 38
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -651,7 +651,7 @@
 
             # Prepare safe filename (preserve existing .pdf if present)
             name = (row.name or "document").strip().replace("\r", "").replace("\n", "")
-            if not name.lower().endswith(".pdf"):
+            if not not name.lower().endswith(".pdf"):
                 name = f"{name}.pdf"
 
             # Stat via the same FD to avoid TOCTOU
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/AddNot, occurrence: 39
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -668,7 +668,7 @@
             )
 
             # Strong validator
-            if isinstance(row.sha256_hex, str) and row.sha256_hex:
+            if not isinstance(row.sha256_hex, str) and row.sha256_hex:
                 resp.set_etag(row.sha256_hex.lower())
 
             # Headers
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001341058201Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001341962369Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.24s

operator: core/AddNot, occurrence: 40
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -693,7 +693,7 @@
     @app.get("/api/get-version/<link>")
     def get_version(link: str):
         # Accept both 32-char (RMAP session secrets) and 64-char (SHA-256 style) tokens
-        if not re.fullmatch(r"[0-9a-f]{32}|[0-9a-f]{64}", link):
+        if not not re.fullmatch(r"[0-9a-f]{32}|[0-9a-f]{64}", link):
             app.logger.warning("Invalid version link format: %s", link)
             return jsonify({"error": "document not found"}), 404
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/AddNot, occurrence: 41
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -715,7 +715,7 @@
             inc_db_error("get_version")
             return jsonify({"error": "database error"}), 503
 
-        if not row:
+        if not not row:
             app.logger.warning("Version not found for link: %s", link)
             return jsonify({"error": "document not found"}), 404
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/AddNot, occurrence: 42
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -727,7 +727,7 @@
             )
             return jsonify({"error": "document path invalid"}), 500
 
-        if not resolved.exists():
+        if not not resolved.exists():
             app.logger.error("File missing on disk for version link=%s", link)
             return jsonify({"error": "file missing on disk"}), 410
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T174354348900Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T174355336630Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.34s

operator: core/AddNot, occurrence: 43
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if not header != b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.32s

operator: core/AddNot, occurrence: 44
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -749,7 +749,7 @@
             return jsonify({"error": "error serving file"}), 500
 
         download_name = (
-            row.link if row.link.lower().endswith(".pdf") else f"{row.link}.pdf"
+            row.link if not row.link.lower().endswith(".pdf") else f"{row.link}.pdf"
         )
         safe_download = download_name.replace("\r", "").replace("\n", "")
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T181430250783Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T181431198463Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.51s

operator: core/AddNot, occurrence: 45
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -781,7 +781,7 @@
     def _safe_resolve_under_storage(p: str, storage_root: Path) -> Path:
         storage_root = storage_root.resolve()
         fp = Path(p)
-        if not fp.is_absolute():
+        if not not fp.is_absolute():
             fp = storage_root / fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 20.67s

operator: core/AddNot, occurrence: 46
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -785,7 +785,7 @@
             fp = storage_root / fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
-        if hasattr(fp, "is_relative_to"):
+        if not hasattr(fp, "is_relative_to"):
             if not fp.is_relative_to(storage_root):
                 raise RuntimeError(f"path {fp} escapes storage root {storage_root}")
         else:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.00s

operator: core/AddNot, occurrence: 47
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -786,7 +786,7 @@
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
-            if not fp.is_relative_to(storage_root):
+            if not not fp.is_relative_to(storage_root):
                 raise RuntimeError(f"path {fp} escapes storage root {storage_root}")
         else:
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.32s

operator: core/AddNot, occurrence: 48
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -803,7 +803,7 @@
     @require_auth
     def delete_document(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
-        if document_id in (None, ""):
+        if not document_id in (None, ""):
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:814 Document id required for deletion

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1ecc8f7d9d354609: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.64s

operator: core/AddNot, occurrence: 49
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -810,7 +810,7 @@
                 or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
 
-        if document_id is None:
+        if not document_id is None:
             app.logger.warning("Document id required for deletion")
             return jsonify({"error": "document id required"}), 400
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011457256916Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011458247966Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:814 Document id required for deletion

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

8 failed, 6 passed, 22 warnings in 19.40s

operator: core/AddNot, occurrence: 50
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if not doc_id <= 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.76s

operator: core/AddNot, occurrence: 51
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -845,7 +845,7 @@
             inc_db_error("delete_document_select")
             return jsonify({"error": "database error during delete"}), 503
 
-        if not row:
+        if not not row:
             # DonÔÇÖt reveal othersÔÇÖ docsÔÇöjust say not found
             app.logger.warning(
                 "Document not found or access denied for deletion id=%s", doc_id
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T021910196648Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T021911018089Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 18.96s

operator: core/AddNot, occurrence: 52
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -859,7 +859,7 @@
         delete_error = None
         try:
             fp = _safe_resolve_under_storage(row.path, storage_root)
-            if fp.exists():
+            if not fp.exists():
                 try:
                     fp.unlink()
                     file_deleted = True
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:90: in write_binary

    new_stream.write(s)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.00s

operator: core/AddNot, occurrence: 53
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -908,7 +908,7 @@
     @require_auth
     def create_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
-        if not document_id:
+        if not not document_id:
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:934 Missing document id in request

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e09be400c516ae99f: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.33s

operator: core/AddNot, occurrence: 54
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -930,7 +930,7 @@
 
         # validate input
         try:
-            if doc_id is None:
+            if not doc_id is None:
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:934 Missing document id in request

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ecfdb47fb8604bb98: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.76s

operator: core/AddNot, occurrence: 55
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if not doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010213442695Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010214260537Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.24s

operator: core/AddNot, occurrence: 56
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -939,7 +939,7 @@
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
-        if (
+        if not (
             not method
             or not intended_for
             or not isinstance(secret, str)
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 63 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'method': 'robust-xmp', 'position': 'metadata-only', 'secret': 'secret'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.00s

operator: core/AddNot, occurrence: 57
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -968,7 +968,7 @@
             app.logger.error("Database error fetching document %s", e)
             return jsonify({"error": "database error"}), 503
 
-        if not row:
+        if not not row:
             app.logger.warning(
                 "Document not found or access denied for watermarking id=%s", doc_id
             )
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

1 failed, 13 passed, 22 warnings in 20.10s

operator: core/AddNot, occurrence: 58
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -977,7 +977,7 @@
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
-        if not file_path.is_absolute():
+        if not not file_path.is_absolute():
             file_path = storage_root / file_path
         file_path = file_path.resolve()
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.51s

operator: core/AddNot, occurrence: 59
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -985,7 +985,7 @@
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
             return jsonify({"error": "document path invalid"}), 500
-        if not file_path.exists():
+        if not not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T154653527648Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T154654444611Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.29s

operator: core/AddNot, occurrence: 60
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if not applicable is False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T222420750216Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T222421660649Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.68s

operator: core/AddNot, occurrence: 61
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 44 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1026 Watermarking produced no output for document 1 using method robust-xmp

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.36s

operator: core/AddNot, occurrence: 62
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1145,7 +1145,7 @@
     @require_auth
     def read_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
-        if not document_id:
+        if not not document_id:
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 19.96s

operator: core/AddNot, occurrence: 63
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1165,7 +1165,7 @@
 
         # validate input
         try:
-            if doc_id is None:
+            if not doc_id is None:
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.29s

operator: core/AddNot, occurrence: 64
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if not doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.82s

operator: core/AddNot, occurrence: 65
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1174,7 +1174,7 @@
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
-        if not method or not isinstance(method, str) or not isinstance(key, str):
+        if not not method or not isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
 
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 41 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1178 Missing required fields for watermarking: {'id': 2, 'key': 'strong-password', 'method': 'overlay-watermark', 'position': 'metadata-only'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 19.81s

operator: core/AddNot, occurrence: 66
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1198,7 +1198,7 @@
             )
             return jsonify({"error": "database error"}), 503
 
-        if not row:
+        if not not row:
             app.logger.warning(
                 "Document not found or access denied for watermark read id=%s", doc_id
             )
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045320894755Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045321911208Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.36s

operator: core/AddNot, occurrence: 67
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1207,7 +1207,7 @@
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
-        if not file_path.is_absolute():
+        if not not file_path.is_absolute():
             file_path = storage_root / file_path
         file_path = file_path.resolve()
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.57s

operator: core/AddNot, occurrence: 68
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1215,7 +1215,7 @@
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
             return jsonify({"error": "document path invalid"}), 500
-        if not file_path.exists():
+        if not not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
 
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 410 == 201

E        +  where 410 = <WrapperTestResponse 33 bytes [410 GONE]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1219 File missing on disk for document id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 410 == 201

1 failed, 13 passed, 22 warnings in 19.97s

operator: core/AddNot, occurrence: 69
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if not provided != token_required:
             return False
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.35s

operator: core/AddNot, occurrence: 70
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1246,7 +1246,7 @@
 
     @app.get("/metrics")
     def metrics():
-        if not _is_authorized_metrics_request():
+        if not not _is_authorized_metrics_request():
             # Obscure existence a bit ÔÇô return 404 instead of 403 to casual scans
             app.logger.warning(
                 "Unauthorized metrics access attempt from %s", request.remote_addr
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041751675420Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041752661737Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.05s

operator: core/AddNot, occurrence: 71
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if not __name__ == "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
timeout
operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -59,7 +59,7 @@
     app.config["DB_PORT"] = int(os.environ.get("DB_PORT", "3306"))
     app.config["DB_NAME"] = os.environ.get("DB_NAME", "tatou")
 
-    app.config["STORAGE_DIR"].mkdir(parents=True, exist_ok=True)
+    app.config["STORAGE_DIR"].mkdir(parents=False, exist_ok=True)
     app.config["TESTING"] = os.environ.get("TESTING", False)
 
     # --- DB engine only (no Table metadata) ---
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.49s

operator: core/ReplaceTrueWithFalse, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -59,7 +59,7 @@
     app.config["DB_PORT"] = int(os.environ.get("DB_PORT", "3306"))
     app.config["DB_NAME"] = os.environ.get("DB_NAME", "tatou")
 
-    app.config["STORAGE_DIR"].mkdir(parents=True, exist_ok=True)
+    app.config["STORAGE_DIR"].mkdir(parents=True, exist_ok=False)
     app.config["TESTING"] = os.environ.get("TESTING", False)
 
     # --- DB engine only (no Table metadata) ---

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:62: in create_app

    app.config["STORAGE_DIR"].mkdir(parents=True, exist_ok=False)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\pathlib.py:1312: in mkdir

    os.mkdir(self, mode)

E   FileExistsError: [WinError 183] Impossibile creare un file, se il file esiste già: 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T02:08:10+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T02:08:10+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T02:08:11+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T02:08:12+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - FileExistsError: [WinError 183] Impossibile crear...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.25s

operator: core/ReplaceTrueWithFalse, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -73,7 +73,7 @@
         eng = app.config.get("_ENGINE")
         if eng is None:
             try:
-                eng = create_engine(db_url(), pool_pre_ping=True, future=True)
+                eng = create_engine(db_url(), pool_pre_ping=False, future=True)
             except Exception as e:
                 app.logger.critical("Failed to initialize database engine: %s", e)
                 raise
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/ReplaceTrueWithFalse, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -73,7 +73,7 @@
         eng = app.config.get("_ENGINE")
         if eng is None:
             try:
-                eng = create_engine(db_url(), pool_pre_ping=True, future=True)
+                eng = create_engine(db_url(), pool_pre_ping=True, future=False)
             except Exception as e:
                 app.logger.critical("Failed to initialize database engine: %s", e)
                 raise
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:236 Database error in create_user: The 'future' parameter passed to create_engine() may only be set to True.

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:280 Database error in login: The 'future' parameter passed to create_engine() may only be set to True.

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150148419501Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:968 Database error fetching document The 'future' parameter passed to create_engine() may only be set to True.

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150149159267Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:844 DB delete error for doc id=2: The 'future' parameter passed to create_engine() may only be set to True.

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:236 Database error in create_user: The 'future' parameter passed to create_engine() may only be set to True.

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 18.95s

operator: core/ReplaceTrueWithFalse, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -175,7 +175,7 @@
         try:
             with get_engine().connect() as conn:
                 conn.execute(text("SELECT 1"))
-            db_ok = True
+            db_ok = False
         except Exception:
             db_ok = False
         return jsonify(
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e3f9ef1d24dd3c73e: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.59s

operator: core/ReplaceTrueWithFalse, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -191,7 +191,7 @@
             return False, "Invalid email format"
         if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
             return False, "Invalid login format"
-        return True, ""
+        return False, ""
 
     # POST /api/create-user {email, login, password}
     @app.post("/api/create-user")
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 13 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed:

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150432771776Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150433647396Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: 

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.45s

operator: core/ReplaceTrueWithFalse, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -196,7 +196,7 @@
     # POST /api/create-user {email, login, password}
     @app.post("/api/create-user")
     def create_user():
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=False) or {}
         email = (payload.get("email") or "").strip().lower()
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/ReplaceTrueWithFalse, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -241,7 +241,7 @@
     # POST /api/login {login, password}
     @app.post("/api/login")
     def login():
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=False) or {}
         email = (payload.get("email") or "").strip()
         password = payload.get("password") or ""
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ReplaceTrueWithFalse, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -339,7 +339,7 @@
             return jsonify({"error": "invalid filename"}), 400
 
         user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
-        user_dir.mkdir(parents=True, exist_ok=True)
+        user_dir.mkdir(parents=False, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
         final_name = request.form.get("name") or fname
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T184013802261Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T184014765713Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.46s

operator: core/ReplaceTrueWithFalse, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -339,7 +339,7 @@
             return jsonify({"error": "invalid filename"}), 400
 
         user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
-        user_dir.mkdir(parents=True, exist_ok=True)
+        user_dir.mkdir(parents=True, exist_ok=False)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
         final_name = request.form.get("name") or fname
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:342: in upload_document

    user_dir.mkdir(parents=True, exist_ok=False)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/src/storage/files/username')

mode = 511, parents = True, exist_ok = False



    def mkdir(self, mode=0o777, parents=False, exist_ok=False):

        """

        Create a new directory at this given path.

        """

        try:

>           os.mkdir(self, mode)

E           FileExistsError: [WinError 183] Impossibile creare un file, se il file esiste già: 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username'



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\pathlib.py:1312: FileExistsError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:342: in upload_document

    user_dir.mkdir(parents=True, exist_ok=False)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/src/storage/files/username')

mode = 511, parents = True, exist_ok = False



    def mkdir(self, mode=0o777, parents=False, exist_ok=False):

        """

        Create a new directory at this given path.

        """

        try:

>           os.mkdir(self, mode)

E           FileExistsError: [WinError 183] Impossibile creare un file, se il file esiste già: 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username'



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\pathlib.py:1312: FileExistsError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - FileExistsError: [Wi...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - FileExistsError: [Win...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.89s

operator: core/ReplaceTrueWithFalse, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -389,7 +389,7 @@
                     {"id": did},
                 ).one()
         except Exception:
-            stored_path.unlink(missing_ok=True)
+            stored_path.unlink(missing_ok=False)
             app.logger.error(
                 "Database error inserting document path=%s user=%s",
                 stored_path,
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e8e18c6b9f246c844: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.74s

operator: core/ReplaceTrueWithFalse, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -759,7 +759,7 @@
                 mimetype="application/pdf",
                 as_attachment=False,
                 download_name=safe_download,
-                conditional=True,
+                conditional=False,
                 max_age=0,
                 last_modified=last_modified,
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceTrueWithFalse, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -807,7 +807,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json and (request.get_json(silent=False) or {}).get("id"))
             )
 
         if document_id is None:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.94s

operator: core/ReplaceTrueWithFalse, occurrence: 13
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -862,7 +862,7 @@
             if fp.exists():
                 try:
                     fp.unlink()
-                    file_deleted = True
+                    file_deleted = False
                 except Exception as e:
                     delete_error = f"failed to delete file: {e}"
                     app.logger.warning(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.64s

operator: core/ReplaceTrueWithFalse, occurrence: 14
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -869,7 +869,7 @@
                         "Failed to delete file %s for doc id=%s: %s", fp, row.id, e
                     )
             else:
-                file_missing = True
+                file_missing = False
         except RuntimeError as e:
             # Path escapes storage root; refuse to touch the file
             delete_error = str(e)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/ReplaceTrueWithFalse, occurrence: 15
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -893,7 +893,7 @@
 
         return jsonify(
             {
-                "deleted": True,
+                "deleted": False,
                 "id": doc_id,
                 "file_deleted": file_deleted,
                 "file_missing": file_missing,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.91s

operator: core/ReplaceTrueWithFalse, occurrence: 16
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -912,7 +912,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json and (request.get_json(silent=False) or {}).get("id"))
             )
         try:
             doc_id = document_id
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.73s

operator: core/ReplaceTrueWithFalse, occurrence: 17
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -920,7 +920,7 @@
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=False) or {}
         # allow a couple of aliases for convenience
         method = payload.get("method")
         intended_for = payload.get("intended_for")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.60s

operator: core/ReplaceTrueWithFalse, occurrence: 18
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1043,7 +1043,7 @@
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
         dest_dir = file_path.parent / "watermarks"
-        dest_dir.mkdir(parents=True, exist_ok=True)
+        dest_dir.mkdir(parents=False, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
         dest_path = dest_dir / candidate
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054005167213Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054006071617Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.92s

operator: core/ReplaceTrueWithFalse, occurrence: 19
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1043,7 +1043,7 @@
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
         dest_dir = file_path.parent / "watermarks"
-        dest_dir.mkdir(parents=True, exist_ok=True)
+        dest_dir.mkdir(parents=True, exist_ok=False)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
         dest_path = dest_dir / candidate
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1046: in create_watermark

    dest_dir.mkdir(parents=True, exist_ok=False)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/src/storage/files/username/watermarks')

mode = 511, parents = True, exist_ok = False



    def mkdir(self, mode=0o777, parents=False, exist_ok=False):

        """

        Create a new directory at this given path.

        """

        try:

>           os.mkdir(self, mode)

E           FileExistsError: [WinError 183] Impossibile creare un file, se il file esiste già: 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks'



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\pathlib.py:1312: FileExistsError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - FileExistsError: [W...

1 failed, 13 passed, 22 warnings in 21.12s

operator: core/ReplaceTrueWithFalse, occurrence: 20
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1089,7 +1089,7 @@
         except IntegrityError as ie:
             # This should be very rare due to SHA-256 usage, but handle it just in case
             try:
-                dest_path.unlink(missing_ok=True)
+                dest_path.unlink(missing_ok=False)
             except Exception as cleanup_error:
                 app.logger.warning(
                     f"Failed to cleanup file {dest_path}: {cleanup_error}"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/ReplaceTrueWithFalse, occurrence: 21
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1101,7 +1101,7 @@
             return jsonify({"error": "database error during version insert"}), 503
         except Exception:
             try:
-                dest_path.unlink(missing_ok=True)
+                dest_path.unlink(missing_ok=False)
             except Exception as cleanup_error:
                 app.logger.warning(
                     f"Failed to cleanup file {dest_path}: {cleanup_error}"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.28s

operator: core/ReplaceTrueWithFalse, occurrence: 22
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1149,7 +1149,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json and (request.get_json(silent=False) or {}).get("id"))
             )
         try:
             doc_id = document_id
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042051681109Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042052771290Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.92s

operator: core/ReplaceTrueWithFalse, occurrence: 23
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1157,7 +1157,7 @@
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=False) or {}
         # allow a couple of aliases for convenience
         method = payload.get("method")
         position = payload.get("position") or None
...F.....F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e9f747ba8534438a8: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 21.44s

operator: core/ReplaceTrueWithFalse, occurrence: 24
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1242,7 +1242,7 @@
         provided = request.headers.get("X-Metrics-Token", "")
         if provided != token_required:
             return False
-        return True
+        return False
 
     @app.get("/metrics")
     def metrics():
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/ReplaceFalseWithTrue, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -60,7 +60,7 @@
     app.config["DB_NAME"] = os.environ.get("DB_NAME", "tatou")
 
     app.config["STORAGE_DIR"].mkdir(parents=True, exist_ok=True)
-    app.config["TESTING"] = os.environ.get("TESTING", False)
+    app.config["TESTING"] = os.environ.get("TESTING", True)
 
     # --- DB engine only (no Table metadata) ---
     def db_url() -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.45s

operator: core/ReplaceFalseWithTrue, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -177,7 +177,7 @@
                 conn.execute(text("SELECT 1"))
             db_ok = True
         except Exception:
-            db_ok = False
+            db_ok = True
         return jsonify(
             {"message": "The server is up and running.", "db_connected": db_ok}
         ), 200
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceFalseWithTrue, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -186,7 +186,7 @@
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
         if len(email) > 320 or len(login) > 64:
-            return False, "Email or login too long"
+            return True, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
         if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.35s

operator: core/ReplaceFalseWithTrue, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -188,7 +188,7 @@
         if len(email) > 320 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
-            return False, "Invalid email format"
+            return True, "Invalid email format"
         if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
             return False, "Invalid login format"
         return True, ""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.84s

operator: core/ReplaceFalseWithTrue, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -190,7 +190,7 @@
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
         if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
-            return False, "Invalid login format"
+            return True, "Invalid login format"
         return True, ""
 
     # POST /api/create-user {email, login, password}
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e2e68a304639cafc8: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.85s

operator: core/ReplaceFalseWithTrue, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -265,7 +265,7 @@
                     is_valid = check_password_hash(row.hpassword, password)
                 else:
                     # Dummy check to maintain constant time
-                    is_valid = False
+                    is_valid = True
                     row = None
 
                 if not is_valid:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.93s

operator: core/ReplaceFalseWithTrue, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -660,7 +660,7 @@
             resp = send_file(
                 file_path,
                 mimetype="application/pdf",
-                as_attachment=False,
+                as_attachment=True,
                 download_name=name,
                 conditional=False,  # enables 304 if If-Modified-Since/Range handling
                 max_age=0,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/ReplaceFalseWithTrue, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -662,7 +662,7 @@
                 mimetype="application/pdf",
                 as_attachment=False,
                 download_name=name,
-                conditional=False,  # enables 304 if If-Modified-Since/Range handling
+                conditional=True,  # enables 304 if If-Modified-Since/Range handling
                 max_age=0,
                 last_modified=st.st_mtime,
             )
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 20.47s

operator: core/ReplaceFalseWithTrue, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -757,7 +757,7 @@
             resp = send_file(
                 resolved,
                 mimetype="application/pdf",
-                as_attachment=False,
+                as_attachment=True,
                 download_name=safe_download,
                 conditional=True,
                 max_age=0,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/ReplaceFalseWithTrue, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -854,7 +854,7 @@
 
         # Resolve and delete file (best effort)
         storage_root = Path(app.config["STORAGE_DIR"])
-        file_deleted = False
+        file_deleted = True
         file_missing = False
         delete_error = None
         try:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212327125482Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212328074291Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.25s

operator: core/ReplaceFalseWithTrue, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -855,7 +855,7 @@
         # Resolve and delete file (best effort)
         storage_root = Path(app.config["STORAGE_DIR"])
         file_deleted = False
-        file_missing = False
+        file_missing = True
         delete_error = None
         try:
             fp = _safe_resolve_under_storage(row.path, storage_root)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 22.37s

operator: core/ReplaceFalseWithTrue, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable is True:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 22.13s

operator: core/ReplaceFalseWithTrue, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1241,7 +1241,7 @@
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
         if provided != token_required:
-            return False
+            return True
         return True
 
     @app.get("/metrics")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ReplaceAndWithOr, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length or file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.27s

operator: core/ReplaceAndWithOr, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -668,7 +668,7 @@
             )
 
             # Strong validator
-            if isinstance(row.sha256_hex, str) and row.sha256_hex:
+            if isinstance(row.sha256_hex, str) or row.sha256_hex:
                 resp.set_etag(row.sha256_hex.lower())
 
             # Headers
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.00s

operator: core/ReplaceAndWithOr, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -807,7 +807,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json or (request.get_json(silent=True) or {}).get("id"))
             )
 
         if document_id is None:
...........F..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 200 == 404

E        +  where 200 = <WrapperTestResponse streamed [200 OK]>.status_code



..\test\test_api.py:446: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 200 == 404

1 failed, 13 passed, 22 warnings in 20.29s

operator: core/ReplaceAndWithOr, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -912,7 +912,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json or (request.get_json(silent=True) or {}).get("id"))
             )
         try:
             doc_id = document_id
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171115360876Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171116245634Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.39s

operator: core/ReplaceAndWithOr, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1149,7 +1149,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json or (request.get_json(silent=True) or {}).get("id"))
             )
         try:
             doc_id = document_id
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T153448399637Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T153449329253Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.28s

operator: core/ReplaceOrWithAnd, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 and len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041021045964Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041021975581Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.74s

operator: core/ReplaceOrWithAnd, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -196,7 +196,7 @@
     # POST /api/create-user {email, login, password}
     @app.post("/api/create-user")
     def create_user():
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=True) and {}
         email = (payload.get("email") or "").strip().lower()
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033954314842Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033955277621Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.97s

operator: core/ReplaceOrWithAnd, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -197,7 +197,7 @@
     @app.post("/api/create-user")
     def create_user():
         payload = request.get_json(silent=True) or {}
-        email = (payload.get("email") or "").strip().lower()
+        email = (payload.get("email") and "").strip().lower()
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username', 'password': 'password'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T185234343691Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T185235254606Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'service@rmap.su', 'login': 'rmap_service', 'password': 'password_rmap'}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.60s

operator: core/ReplaceOrWithAnd, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -198,7 +198,7 @@
     def create_user():
         payload = request.get_json(silent=True) or {}
         email = (payload.get("email") or "").strip().lower()
-        login = (payload.get("login") or "").strip()
+        login = (payload.get("login") and "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
         if not email or not login or not password:
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username', 'password': 'password'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T210736552917Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T210737549352Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'service@rmap.su', 'login': 'rmap_service', 'password': 'password_rmap'}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 21.39s

operator: core/ReplaceOrWithAnd, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -199,7 +199,7 @@
         payload = request.get_json(silent=True) or {}
         email = (payload.get("email") or "").strip().lower()
         login = (payload.get("login") or "").strip()
-        password = payload.get("password") or ""
+        password = payload.get("password") and ""
         start_db = time.time()
         if not email or not login or not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username', 'password': 'password'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161041580531Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161042536521Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'service@rmap.su', 'login': 'rmap_service', 'password': 'password_rmap'}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.12s

operator: core/ReplaceOrWithAnd, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -201,7 +201,7 @@
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
-        if not email or not login or not password:
+        if not email and not login or not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
             return jsonify({"error": "email, login, and password are required"}), 400
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.39s

operator: core/ReplaceOrWithAnd, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -201,7 +201,7 @@
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
-        if not email or not login or not password:
+        if not email or not login and not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
             return jsonify({"error": "email, login, and password are required"}), 400
 
.F.F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 201  # Endpoint should exist

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("id"), int)

        assert isinstance(resp_data.get("login"), str)

        assert isinstance(resp_data.get("email"), str)

        #check values are what we submitted

        assert resp_data.get("login") == parameters["login"]

        assert resp_data.get("email") == parameters["email"]

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/create-user",json={

                    "login": "username",

                    "password": "password",

                },  # pragma: allowlist secret

        )

        assert resp.status_code == 400

    

        # Missing login

        resp = client.post("/api/create-user",

                json={"email": "user@email.se", "password": "password"},

        )

        assert resp.status_code == 400

    

        # Missing password

        resp = client.post(

        "/api/create-user", json={"email": "user@email.se", "login": "username"}

        )

>       assert resp.status_code == 400

E       assert 409 == 400

E        +  where 409 = <WrapperTestResponse streamed [409 CONFLICT]>.status_code



..\test\test_api.py:102: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'login': 'username', 'password': 'password'}

WARNING  server:server.py:213 User input validation failed: Invalid login format

WARNING  server:server.py:231 Attempt to create duplicate user: email=user@email.se, login=username

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e0f6eff102ee31692: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 409 == 400

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

6 failed, 8 passed, 22 warnings in 19.92s

operator: core/ReplaceOrWithAnd, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -241,7 +241,7 @@
     # POST /api/login {login, password}
     @app.post("/api/login")
     def login():
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=True) and {}
         email = (payload.get("email") or "").strip()
         password = payload.get("password") or ""
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 44 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {}

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061509912780Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061510838137Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 400 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.12s

operator: core/ReplaceOrWithAnd, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -242,7 +242,7 @@
     @app.post("/api/login")
     def login():
         payload = request.get_json(silent=True) or {}
-        email = (payload.get("email") or "").strip()
+        email = (payload.get("email") and "").strip()
         password = payload.get("password") or ""
 
         if not email or not password:
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 44 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'email': 'user@email.se', 'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.27s

operator: core/ReplaceOrWithAnd, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -243,7 +243,7 @@
     def login():
         payload = request.get_json(silent=True) or {}
         email = (payload.get("email") or "").strip()
-        password = payload.get("password") or ""
+        password = payload.get("password") and ""
 
         if not email or not password:
             app.logger.warning("Missing fields in login attempt: %s", payload)
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 44 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'email': 'user@email.se', 'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.12s

operator: core/ReplaceOrWithAnd, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -245,7 +245,7 @@
         email = (payload.get("email") or "").strip()
         password = payload.get("password") or ""
 
-        if not email or not password:
+        if not email and not password:
             app.logger.warning("Missing fields in login attempt: %s", payload)
             return jsonify({"error": "email and password are required"}), 400
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T234854386391Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T234855322823Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.44s

operator: core/ReplaceOrWithAnd, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file and file.filename == "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034629918034Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034630952304Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 20.63s

operator: core/ReplaceOrWithAnd, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -342,7 +342,7 @@
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
-        final_name = request.form.get("name") or fname
+        final_name = request.form.get("name") and fname
         stored_name = f"{ts}__{fname}"
 
         try:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201807093657Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201808231387Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.71s

operator: core/ReplaceOrWithAnd, occurrence: 13
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -456,7 +456,7 @@
     def list_versions(document_id: int | None = None):
         # Input validation
         if document_id is None:
-            document_id = request.args.get("id") or request.args.get("documentid")
+            document_id = request.args.get("id") and request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
                 if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.24s

operator: core/ReplaceOrWithAnd, occurrence: 14
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None and document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.36s

operator: core/ReplaceOrWithAnd, occurrence: 15
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 and document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T225443509858Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T225444475161Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.21s

operator: core/ReplaceOrWithAnd, occurrence: 16
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None and document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.93s

operator: core/ReplaceOrWithAnd, occurrence: 17
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 and document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031006552374Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031007448680Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.25s

operator: core/ReplaceOrWithAnd, occurrence: 18
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -526,7 +526,7 @@
     def list_all_versions():
         try:
             # Validate user data from auth token
-            if not g.user or not g.user.get("id"):
+            if not g.user and not g.user.get("id"):
                 app.logger.error("Missing user info in auth token")
                 return jsonify({"error": "Invalid authentication"}), 401
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T173829078015Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T173830022621Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.39s

operator: core/ReplaceOrWithAnd, occurrence: 19
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -573,7 +573,7 @@
     def get_document(document_id: int | None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
-            document_id = request.args.get("id") or request.args.get("documentid")
+            document_id = request.args.get("id") and request.args.get("documentid")
             try:
                 document_id = int(document_id)
             except (TypeError, ValueError):
.......F......                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 13 passed, 22 warnings in 20.54s

operator: core/ReplaceOrWithAnd, occurrence: 20
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None and document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.92s

operator: core/ReplaceOrWithAnd, occurrence: 21
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 and document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/ReplaceOrWithAnd, occurrence: 22
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -650,7 +650,7 @@
             f.seek(0)
 
             # Prepare safe filename (preserve existing .pdf if present)
-            name = (row.name or "document").strip().replace("\r", "").replace("\n", "")
+            name = (row.name and "document").strip().replace("\r", "").replace("\n", "")
             if not name.lower().endswith(".pdf"):
                 name = f"{name}.pdf"
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 22.13s

operator: core/ReplaceOrWithAnd, occurrence: 23
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -806,7 +806,7 @@
         if document_id in (None, ""):
             document_id = (
                 request.args.get("id")
-                or request.args.get("documentid")
+                and request.args.get("documentid")
                 or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/ReplaceOrWithAnd, occurrence: 24
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -807,7 +807,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                and (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
 
         if document_id is None:
...........F..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:814 Document id required for deletion

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 26.38s

operator: core/ReplaceOrWithAnd, occurrence: 25
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -807,7 +807,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json and (request.get_json(silent=True) and {}).get("id"))
             )
 
         if document_id is None:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:814 Document id required for deletion

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e70cdb33a21ad7f3d: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.87s

operator: core/ReplaceOrWithAnd, occurrence: 26
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 and doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.94s

operator: core/ReplaceOrWithAnd, occurrence: 27
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -911,7 +911,7 @@
         if not document_id:
             document_id = (
                 request.args.get("id")
-                or request.args.get("documentid")
+                and request.args.get("documentid")
                 or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
         try:
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T023826001639Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T023826955094Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.37s

operator: core/ReplaceOrWithAnd, occurrence: 28
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -912,7 +912,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                and (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
         try:
             doc_id = document_id
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T222807693015Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:934 Missing document id in request

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T222808544552Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.60s

operator: core/ReplaceOrWithAnd, occurrence: 29
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -912,7 +912,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json and (request.get_json(silent=True) and {}).get("id"))
             )
         try:
             doc_id = document_id
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:934 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.21s

operator: core/ReplaceOrWithAnd, occurrence: 30
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -920,7 +920,7 @@
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=True) and {}
         # allow a couple of aliases for convenience
         method = payload.get("method")
         intended_for = payload.get("intended_for")
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 63 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:948 Missing required fields for watermarking: {}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.31s

operator: core/ReplaceOrWithAnd, occurrence: 31
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -924,7 +924,7 @@
         # allow a couple of aliases for convenience
         method = payload.get("method")
         intended_for = payload.get("intended_for")
-        position = payload.get("position") or None
+        position = payload.get("position") and None
         secret = payload.get("secret")
         key = payload.get("key")
 
...F.....F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

>       assert isinstance(data.get("position"), str)

E       AssertionError: assert False

E        +  where False = isinstance(None, str)

E        +    where None = <built-in method get of dict object at 0x000002A111761E40>('position')

E        +      where <built-in method get of dict object at 0x000002A111761E40> = {'documentid': 1, 'filename': 'My File__Mickey_Mouse.pdf', 'id': 1, 'intended_for': 'Mickey Mouse', ...}.get



..\test\test_api.py:330: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - AssertionError: ass...

2 failed, 12 passed, 22 warnings in 19.82s

operator: core/ReplaceOrWithAnd, occurrence: 32
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 and doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T043031432502Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T043032790085Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 21.37s

operator: core/ReplaceOrWithAnd, occurrence: 33
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -941,7 +941,7 @@
             return jsonify({"error": "document_id (int) is required"}), 400
         if (
             not method
-            or not intended_for
+            and not intended_for
             or not isinstance(secret, str)
             or not isinstance(key, str)
         ):
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

        assert resp.status_code == 201

        #Missing key

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing secret

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                         "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing recipient

>       resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret",  "id": 1})



..\test\test_api.py:373: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1044: in create_watermark

    intended_slug = secure_filename(intended_for)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



filename = None



    def secure_filename(filename: str) -> str:

        r"""Pass it a filename and it will return a secure version of it.  This

        filename can then safely be stored on a regular file system and passed

        to :func:`os.path.join`.  The filename returned is an ASCII only string

        for maximum portability.

    

        On windows systems the function also makes sure that the file is not

        named after one of the special device files.

    

        >>> secure_filename("My cool movie.mov")

        'My_cool_movie.mov'

        >>> secure_filename("../../../etc/passwd")

        'etc_passwd'

        >>> secure_filename('i contain cool \xfcml\xe4uts.txt')

        'i_contain_cool_umlauts.txt'

    

        The function might return an empty filename.  It's your responsibility

        to ensure that the filename is unique and that you abort or

        generate a random filename if the function returned an empty one.

    

        .. versionadded:: 0.5

    

        :param filename: the filename to secure

        """

>       filename = unicodedata.normalize("NFKD", filename)

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: normalize() argument 2 must be str, not None



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:219: TypeError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: None. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'method': 'robust-xmp', 'position': 'metadata-only', 'secret': 'secret'}

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'method': 'robust-xmp', 'position': 'metadata-only'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: normaliz...

1 failed, 13 passed, 22 warnings in 20.47s

operator: core/ReplaceOrWithAnd, occurrence: 34
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -942,7 +942,7 @@
         if (
             not method
             or not intended_for
-            or not isinstance(secret, str)
+            and not isinstance(secret, str)
             or not isinstance(key, str)
         ):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

        assert resp.status_code == 201

        #Missing key

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing secret

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                         "intended_for":"Mickey Mouse", "id": 1})

>       assert resp.status_code == 400

E       assert 500 == 400

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:371: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'method': 'robust-xmp', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: 'NoneType' object has no attribute 'strip'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 400

1 failed, 13 passed, 22 warnings in 20.32s

operator: core/ReplaceOrWithAnd, occurrence: 35
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -943,7 +943,7 @@
             not method
             or not intended_for
             or not isinstance(secret, str)
-            or not isinstance(key, str)
+            and not isinstance(key, str)
         ):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify(
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

        assert resp.status_code == 201

        #Missing key

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

>       assert resp.status_code == 400

E       assert 500 == 400

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:367: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: 'NoneType' object has no attribute 'strip'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 400

1 failed, 13 passed, 22 warnings in 20.35s

operator: core/ReplaceOrWithAnd, occurrence: 36
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) and len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.99s

operator: core/ReplaceOrWithAnd, occurrence: 37
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1040,7 +1040,7 @@
             return jsonify({"error": "watermarking failed"}), 500
 
         # build destination file name: "<original_name>__<intended_to>.pdf"
-        base_name = Path(row.name or file_path.name).stem
+        base_name = Path(row.name and file_path.name).stem
         intended_slug = secure_filename(intended_for)
         dest_dir = file_path.parent / "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.58s

operator: core/ReplaceOrWithAnd, occurrence: 38
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1081,7 +1081,7 @@
                         "intended_for": intended_for,
                         "secret": secret,
                         "method": method,
-                        "position": position or "",
+                        "position": position and "",
                         "path": str(dest_path),
                     },
                 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.17s

operator: core/ReplaceOrWithAnd, occurrence: 39
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1148,7 +1148,7 @@
         if not document_id:
             document_id = (
                 request.args.get("id")
-                or request.args.get("documentid")
+                and request.args.get("documentid")
                 or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.57s

operator: core/ReplaceOrWithAnd, occurrence: 40
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1149,7 +1149,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                and (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
         try:
             doc_id = document_id
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 20.03s

operator: core/ReplaceOrWithAnd, occurrence: 41
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1149,7 +1149,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json and (request.get_json(silent=True) and {}).get("id"))
             )
         try:
             doc_id = document_id
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 21.22s

operator: core/ReplaceOrWithAnd, occurrence: 42
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1157,7 +1157,7 @@
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=True) and {}
         # allow a couple of aliases for convenience
         method = payload.get("method")
         position = payload.get("position") or None
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 41 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1178 Missing required fields for watermarking: {}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 19.88s

operator: core/ReplaceOrWithAnd, occurrence: 43
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1160,7 +1160,7 @@
         payload = request.get_json(silent=True) or {}
         # allow a couple of aliases for convenience
         method = payload.get("method")
-        position = payload.get("position") or None
+        position = payload.get("position") and None
         key = payload.get("key")
 
         # validate input
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("secret"), str)

        assert isinstance(data.get("method"), str)

>       assert isinstance(data.get("position"), str)

E       AssertionError: assert False

E        +  where False = isinstance(None, str)

E        +    where None = <built-in method get of dict object at 0x0000021127C1D700>('position')

E        +      where <built-in method get of dict object at 0x0000021127C1D700> = {'documentid': 2, 'method': 'overlay-watermark', 'position': None, 'secret': 'hidden-example-value'}.get



..\test\test_api.py:406: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

1 failed, 13 passed, 22 warnings in 21.39s

operator: core/ReplaceOrWithAnd, occurrence: 44
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 and doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.13s

operator: core/ReplaceOrWithAnd, occurrence: 45
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1174,7 +1174,7 @@
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
-        if not method or not isinstance(method, str) or not isinstance(key, str):
+        if not method and not isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.34s

operator: core/ReplaceOrWithAnd, occurrence: 46
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1174,7 +1174,7 @@
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
-        if not method or not isinstance(method, str) or not isinstance(key, str):
+        if not method or not isinstance(method, str) and not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.17s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -39,7 +39,7 @@
         from rmap_handler import RMAPHandler as _RMAPHandler  # type: ignore
 
         RMAPHandler = _RMAPHandler
-    except Exception:  # pragma: no cover - degrade gracefully if missing
+    except CosmicRayTestingException:  # pragma: no cover - degrade gracefully if missing
         RMAPHandler = None  # type: ignore
 
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.98s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -74,7 +74,7 @@
         if eng is None:
             try:
                 eng = create_engine(db_url(), pool_pre_ping=True, future=True)
-            except Exception as e:
+            except CosmicRayTestingException as e:
                 app.logger.critical("Failed to initialize database engine: %s", e)
                 raise
             app.config["_ENGINE"] = eng
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/ExceptionReplacer, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -84,7 +84,7 @@
     if RMAPHandler is not None:
         try:
             RMAPHandler(app, str(app.config["STORAGE_DIR"]), get_engine)
-        except Exception as e:  # pragma: no cover - defensive; don't fail app
+        except CosmicRayTestingException as e:  # pragma: no cover - defensive; don't fail app
             app.logger.warning("RMAP initialization failed (continuing): %s", e)
 
     # --- Helpers ---
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.92s

operator: core/ExceptionReplacer, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -109,7 +109,7 @@
                 data = _serializer().loads(
                     token, max_age=app.config["TOKEN_TTL_SECONDS"]
                 )
-            except SignatureExpired:
+            except CosmicRayTestingException:
                 return _auth_error("Token expired")
             except BadSignature:
                 return _auth_error("Invalid token")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/ExceptionReplacer, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -111,7 +111,7 @@
                 )
             except SignatureExpired:
                 return _auth_error("Token expired")
-            except BadSignature:
+            except CosmicRayTestingException:
                 return _auth_error("Invalid token")
             g.user = {
                 "id": int(data["uid"]),
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.43s

operator: core/ExceptionReplacer, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -143,7 +143,7 @@
                 cl = request.content_length
                 if cl is not None:
                     observe_request_size(request.method, route, cl)
-            except Exception as exc:  # pragma: no cover - soft fail
+            except CosmicRayTestingException as exc:  # pragma: no cover - soft fail
                 app.logger.warning("Request size capture failed: %s", exc)
         except Exception as exc:  # pragma: no cover - defensive
             app.logger.warning("before_request instrumentation failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ExceptionReplacer, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -145,7 +145,7 @@
                     observe_request_size(request.method, route, cl)
             except Exception as exc:  # pragma: no cover - soft fail
                 app.logger.warning("Request size capture failed: %s", exc)
-        except Exception as exc:  # pragma: no cover - defensive
+        except CosmicRayTestingException as exc:  # pragma: no cover - defensive
             app.logger.warning("before_request instrumentation failed: %s", exc)
 
     @app.after_request  # type: ignore
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T191145364017Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T191146301995Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.74s

operator: core/ExceptionReplacer, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -156,7 +156,7 @@
                 dur = time.time() - start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
-        except Exception as exc:  # pragma: no cover - defensive
+        except CosmicRayTestingException as exc:  # pragma: no cover - defensive
             app.logger.warning("after_request instrumentation failed: %s", exc)
         return resp
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/ExceptionReplacer, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -176,7 +176,7 @@
             with get_engine().connect() as conn:
                 conn.execute(text("SELECT 1"))
             db_ok = True
-        except Exception:
+        except CosmicRayTestingException:
             db_ok = False
         return jsonify(
             {"message": "The server is up and running.", "db_connected": db_ok}
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.16s

operator: core/ExceptionReplacer, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -227,7 +227,7 @@
                     {"id": uid},
                 ).one()
             observe_db_latency("create_user", time.time() - start_db)
-        except IntegrityError:
+        except CosmicRayTestingException:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/ExceptionReplacer, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -232,7 +232,7 @@
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
             )
             return jsonify({"error": "email or login already exists"}), 409
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("Database error in create_user: %s", e)
             return jsonify({"error": "database error"}), 503
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/ExceptionReplacer, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -276,7 +276,7 @@
                     inc_login_failure("invalid_credentials")
                     return jsonify({"error": "invalid credentials"}), 401
 
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("Database error in login: %s", e)
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ea989e79a57fc48fb: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 22.40s

operator: core/ExceptionReplacer, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -353,7 +353,7 @@
                 return jsonify({"error": "invalid path"}), 400
 
             file.save(stored_path)
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("File save error: %s", e)
             return jsonify({"error": "failed to save file"}), 500
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.59s

operator: core/ExceptionReplacer, occurrence: 13
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -388,7 +388,7 @@
                     ),
                     {"id": did},
                 ).one()
-        except Exception:
+        except CosmicRayTestingException:
             stored_path.unlink(missing_ok=True)
             app.logger.error(
                 "Database error inserting document path=%s user=%s",
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.43s

operator: core/ExceptionReplacer, occurrence: 14
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -428,7 +428,7 @@
                     ),
                     {"uid": int(g.user["id"])},
                 ).all()
-        except Exception:
+        except CosmicRayTestingException:
             app.logger.error(
                 "Database error in list_documents for user=%s", g.user["id"]
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.87s

operator: core/ExceptionReplacer, occurrence: 15
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -462,7 +462,7 @@
                 if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
-            except (TypeError, ValueError):
+            except (CosmicRayTestingException, ValueError):
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e07a751c98e6e9e30: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.70s

operator: core/ExceptionReplacer, occurrence: 16
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -462,7 +462,7 @@
                 if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
-            except (TypeError, ValueError):
+            except (TypeError, CosmicRayTestingException):
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.75s

operator: core/ExceptionReplacer, occurrence: 17
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -500,7 +500,7 @@
                     """),
                     {"did": document_id, "uid": int(g.user["id"])},
                 ).all()
-        except Exception:
+        except CosmicRayTestingException:
             app.logger.error(
                 f"Database error in list_versions: {document_id},{g.user['id']}"
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.02s

operator: core/ExceptionReplacer, occurrence: 18
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -544,7 +544,7 @@
                     ),
                     {"uid": int(g.user["id"])},
                 ).all()
-        except ValueError:
+        except CosmicRayTestingException:
             app.logger.error("Invalid user ID in auth token")
             return jsonify({"error": "Authentication error"}), 401
         except Exception:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.84s

operator: core/ExceptionReplacer, occurrence: 19
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -547,7 +547,7 @@
         except ValueError:
             app.logger.error("Invalid user ID in auth token")
             return jsonify({"error": "Authentication error"}), 401
-        except Exception:
+        except CosmicRayTestingException:
             app.logger.error(
                 "Database error in list_all_versions for user=%s", g.user["id"]
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.95s

operator: core/ExceptionReplacer, occurrence: 20
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -576,7 +576,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id)
-            except (TypeError, ValueError):
+            except (CosmicRayTestingException, ValueError):
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020933726038Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020934658199Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.27s

operator: core/ExceptionReplacer, occurrence: 21
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -576,7 +576,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id)
-            except (TypeError, ValueError):
+            except (TypeError, CosmicRayTestingException):
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
.......F......                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



document_id = None



    @app.get("/api/get-document")

    @app.get("/api/get-document/<int:document_id>")

    @require_auth

    def get_document(document_id: int | None = None):

        # Support both path param and ?id=/ ?documentid=

        if document_id is None:

            document_id = request.args.get("id") or request.args.get("documentid")

            try:

>               document_id = int(document_id)

                              ^^^^^^^^^^^^^^^^

E               TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'



server.py:578: TypeError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        #Test with no parameters

>       resp = client.get("/api/get-document")

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:286: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = None



    @app.get("/api/get-document")

    @app.get("/api/get-document/<int:document_id>")

    @require_auth

    def get_document(document_id: int | None = None):

        # Support both path param and ?id=/ ?documentid=

        if document_id is None:

            document_id = request.args.get("id") or request.args.get("documentid")

            try:

                document_id = int(document_id)

>           except (TypeError, CosmicRayTestingException):

                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E           NameError: name 'CosmicRayTestingException' is not defined



server.py:579: NameError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - NameError: name 'Cosmic...

1 failed, 13 passed, 22 warnings in 20.75s

operator: core/ExceptionReplacer, occurrence: 22
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -596,7 +596,7 @@
                     ),
                     {"id": document_id, "uid": int(g.user["id"])},
                 ).first()
-        except Exception:
+        except CosmicRayTestingException:
             app.logger.error(
                 f"Database error in get_document: {document_id},{g.user['id']}"
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ExceptionReplacer, occurrence: 23
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -619,7 +619,7 @@
         try:
             resolved = file_path.resolve()
             resolved.relative_to(storage_root)
-        except Exception:
+        except CosmicRayTestingException:
             # Path looks suspicious or outside storage
             app.logger.warning(
                 "Rejected document path for id %s: %s", document_id, row.path
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.24s

operator: core/ExceptionReplacer, occurrence: 24
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -633,7 +633,7 @@
         # TOCTOU-safe open and validation
         try:
             f = open(resolved, "rb")
-        except OSError:
+        except CosmicRayTestingException:
             app.logger.error("File missing on disk for document id=%s", document_id)
             return jsonify({"error": "file missing on disk"}), 410
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.17s

operator: core/ExceptionReplacer, occurrence: 25
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -681,7 +681,7 @@
             )
 
             return resp
-        except Exception as e:
+        except CosmicRayTestingException as e:
             f.close()
             # Log error and return generic message
             app.logger.error(
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T235158263733Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T235159147429Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.30s

operator: core/ExceptionReplacer, occurrence: 26
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -710,7 +710,7 @@
                     ),
                     {"link": link},
                 ).first()
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("Database error in get_version: %s", e)
             inc_db_error("get_version")
             return jsonify({"error": "database error"}), 503
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ExceptionReplacer, occurrence: 27
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -721,7 +721,7 @@
 
         try:
             resolved = _safe_resolve_under_storage(row.path, app.config["STORAGE_DIR"])
-        except Exception as exc:
+        except CosmicRayTestingException as exc:
             app.logger.warning(
                 "Rejected version path for link %s: %s (%s)", link, row.path, exc
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/ExceptionReplacer, occurrence: 28
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -741,7 +741,7 @@
                     return jsonify({"error": "document not available"}), 415
                 fh.seek(0)
                 last_modified = os.fstat(fh.fileno()).st_mtime
-        except OSError:
+        except CosmicRayTestingException:
             app.logger.error("File missing on disk for version link=%s", link)
             return jsonify({"error": "file missing on disk"}), 410
         except Exception as e:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/ExceptionReplacer, occurrence: 29
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -744,7 +744,7 @@
         except OSError:
             app.logger.error("File missing on disk for version link=%s", link)
             return jsonify({"error": "file missing on disk"}), 410
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("Error inspecting version file for %s: %s", link, e)
             return jsonify({"error": "error serving file"}), 500
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ExceptionReplacer, occurrence: 30
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -763,7 +763,7 @@
                 max_age=0,
                 last_modified=last_modified,
             )
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("Error serving version %s: %s", link, e)
             return jsonify({"error": "error serving file"}), 500
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/ExceptionReplacer, occurrence: 31
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -791,7 +791,7 @@
         else:
             try:
                 fp.relative_to(storage_root)
-            except ValueError:
+            except CosmicRayTestingException:
                 raise RuntimeError(
                     f"path {fp} escapes storage root {storage_root}"
                 ) from None
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.04s

operator: core/ExceptionReplacer, occurrence: 32
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -816,7 +816,7 @@
 
         try:
             doc_id = int(document_id)
-        except (TypeError, ValueError):
+        except (CosmicRayTestingException, ValueError):
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T140942720599Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T140943747891Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 20.53s

operator: core/ExceptionReplacer, occurrence: 33
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -816,7 +816,7 @@
 
         try:
             doc_id = int(document_id)
-        except (TypeError, ValueError):
+        except (TypeError, CosmicRayTestingException):
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.45s

operator: core/ExceptionReplacer, occurrence: 34
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -840,7 +840,7 @@
                     ),
                     {"id": doc_id, "owner": owner_id},
                 ).first()
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("DB delete error for doc id=%s: %s", doc_id, e)
             inc_db_error("delete_document_select")
             return jsonify({"error": "database error during delete"}), 503
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.73s

operator: core/ExceptionReplacer, occurrence: 35
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -863,7 +863,7 @@
                 try:
                     fp.unlink()
                     file_deleted = True
-                except Exception as e:
+                except CosmicRayTestingException as e:
                     delete_error = f"failed to delete file: {e}"
                     app.logger.warning(
                         "Failed to delete file %s for doc id=%s: %s", fp, row.id, e
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.29s

operator: core/ExceptionReplacer, occurrence: 36
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -870,7 +870,7 @@
                     )
             else:
                 file_missing = True
-        except RuntimeError as e:
+        except CosmicRayTestingException as e:
             # Path escapes storage root; refuse to touch the file
             delete_error = str(e)
             app.logger.error("Path safety check failed for doc id=%s: %s", row.id, e)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T173208265515Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T173209183503Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.35s

operator: core/ExceptionReplacer, occurrence: 37
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -886,7 +886,7 @@
                     text("DELETE FROM Documents WHERE id = :id AND ownerid = :owner"),
                     {"id": doc_id, "owner": owner_id},
                 )
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("DB delete error for doc id=%s: %s", doc_id, e)
             inc_db_error("delete_document_delete")
             return jsonify({"error": "database error during delete"}), 503
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.32s

operator: core/ExceptionReplacer, occurrence: 38
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -916,7 +916,7 @@
             )
         try:
             doc_id = document_id
-        except (TypeError, ValueError):
+        except (CosmicRayTestingException, ValueError):
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061116137476Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061117184046Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 21.46s

operator: core/ExceptionReplacer, occurrence: 39
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -916,7 +916,7 @@
             )
         try:
             doc_id = document_id
-        except (TypeError, ValueError):
+        except (TypeError, CosmicRayTestingException):
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
...F.....FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

4 failed, 10 passed, 22 warnings in 22.19s

operator: core/ExceptionReplacer, occurrence: 40
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -936,7 +936,7 @@
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
-        except (TypeError, ValueError):
+        except (CosmicRayTestingException, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
         if (
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.99s

operator: core/ExceptionReplacer, occurrence: 41
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -936,7 +936,7 @@
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
-        except (TypeError, ValueError):
+        except (TypeError, CosmicRayTestingException):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
         if (
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ExceptionReplacer, occurrence: 42
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -964,7 +964,7 @@
                     ),
                     {"id": doc_id, "owner": int(g.user["id"])},
                 ).first()
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("Database error fetching document %s", e)
             return jsonify({"error": "database error"}), 503
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.92s

operator: core/ExceptionReplacer, occurrence: 43
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -982,7 +982,7 @@
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
-        except ValueError:
+        except CosmicRayTestingException:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
             return jsonify({"error": "document path invalid"}), 500
         if not file_path.exists():
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.99s

operator: core/ExceptionReplacer, occurrence: 44
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1002,7 +1002,7 @@
                     doc_id,
                 )
                 return jsonify({"error": "watermarking method not applicable"}), 400
-        except Exception as e:
+        except CosmicRayTestingException as e:
             inc_watermark_failed(method, "applicability_exception")
             app.logger.error(
                 "Watermark applicability check failed for document %s: %s", doc_id, e
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



method = 'watermarkmethod'



    def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:

        """Resolve a method from a string name or pass-through an instance.

    

        Raises

        ------

        KeyError

            If ``method`` is a string not present in :data:`METHODS`.

        """

        if isinstance(method, WatermarkingMethod):

            return method

        try:

>           return METHODS[method]

                   ^^^^^^^^^^^^^^^

E           KeyError: 'watermarkmethod'



watermarking_utils.py:79: KeyError



The above exception was the direct cause of the following exception:



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

>           applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )



server.py:994: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:112: in is_watermarking_applicable

    m = get_method(method)

        ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



method = 'watermarkmethod'



    def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:

        """Resolve a method from a string name or pass-through an instance.

    

        Raises

        ------

        KeyError

            If ``method`` is a string not present in :data:`METHODS`.

        """

        if isinstance(method, WatermarkingMethod):

            return method

        try:

            return METHODS[method]

        except KeyError as exc:

>           raise KeyError(

                f"Unknown watermarking method: {method!r}. Known: {sorted(METHODS)}"

            ) from exc

E           KeyError: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"



watermarking_utils.py:81: KeyError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

>       resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})



..\test\test_api.py:344: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

>       except CosmicRayTestingException as e:

               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       NameError: name 'CosmicRayTestingException' is not defined



server.py:1005: NameError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - NameError: name 'Co...

1 failed, 13 passed, 22 warnings in 20.80s

operator: core/ExceptionReplacer, occurrence: 45
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1029,7 +1029,7 @@
                     method,
                 )
                 return jsonify({"error": "watermarking produced no output"}), 500
-        except Exception as e:
+        except CosmicRayTestingException as e:
             inc_watermark_failed(method, "exception")
             app.logger.error(
                 "Watermarking failed for document %s using method %s: %s",
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e35662a3600e8b7eb: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.91s

operator: core/ExceptionReplacer, occurrence: 46
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1052,7 +1052,7 @@
         try:
             with dest_path.open("wb") as f:
                 f.write(wm_bytes)
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error(
                 "Failed to write watermarked file %s for document %s: %s",
                 dest_path,
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

        dest_path = dest_dir / candidate

    

        # write bytes

        try:

            with dest_path.open("wb") as f:

>               f.write(wm_bytes)

E               OSError: [Errno 28] No space left on device



server.py:1054: OSError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

        dest_path = dest_dir / candidate

    

        # write bytes

        try:

            with dest_path.open("wb") as f:

                f.write(wm_bytes)

>       except CosmicRayTestingException as e:

               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       NameError: name 'CosmicRayTestingException' is not defined



server.py:1055: NameError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e79c08b104483925c: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - NameError: name 'Co...

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.66s

operator: core/ExceptionReplacer, occurrence: 47
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1086,7 +1086,7 @@
                     },
                 )
                 vid = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())
-        except IntegrityError as ie:
+        except CosmicRayTestingException as ie:
             # This should be very rare due to SHA-256 usage, but handle it just in case
             try:
                 dest_path.unlink(missing_ok=True)
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



self = <sqlalchemy.engine.base.Connection object at 0x00000235B9E95100>

dialect = <sqlalchemy.dialects.mysql.pymysql.MySQLDialect_pymysql object at 0x00000235B9E1A090>

context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mysqldb object at 0x00000235B9DD8440>

statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb object at 0x00000235B9E2BF80>

parameters = [{'documentid': 1, 'intended_for': 'Mickey Mouse', 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'method': 'robust-xmp', ...}]



    def _exec_single_context(

        self,

        dialect: Dialect,

        context: ExecutionContext,

        statement: Union[str, Compiled],

        parameters: Optional[_AnyMultiExecuteParams],

    ) -> CursorResult[Any]:

        """continue the _execute_context() method for a single DBAPI

        cursor.execute() or cursor.executemany() call.

    

        """

        if dialect.bind_typing is BindTyping.SETINPUTSIZES:

            generic_setinputsizes = context._prepare_set_input_sizes()

    

            if generic_setinputsizes:

                try:

                    dialect.do_set_input_sizes(

                        context.cursor, generic_setinputsizes, context

                    )

                except BaseException as e:

                    self._handle_dbapi_exception(

                        e, str(statement), parameters, None, context

                    )

    

        cursor, str_statement, parameters = (

            context.cursor,

            context.statement,

            context.parameters,

        )

    

        effective_parameters: Optional[_AnyExecuteParams]

    

        if not context.executemany:

            effective_parameters = parameters[0]

        else:

            effective_parameters = parameters

    

        if self._has_events or self.engine._has_events:

            for fn in self.dispatch.before_cursor_execute:

                str_statement, effective_parameters = fn(

                    self,

                    cursor,

                    str_statement,

                    effective_parameters,

                    context,

                    context.executemany,

                )

    

        if self._echo:

            self._log_info(str_statement)

    

            stats = context._get_cache_stats()

    

            if not self.engine.hide_parameters:

                self._log_info(

                    "[%s] %r",

                    stats,

                    sql_util._repr_params(

                        effective_parameters,

                        batches=10,

                        ismulti=context.executemany,

                    ),

                )

            else:

                self._log_info(

                    "[%s] [SQL parameters hidden due to hide_parameters=True]",

                    stats,

                )

    

        evt_handled: bool = False

        try:

            if context.execute_style is ExecuteStyle.EXECUTEMANY:

                effective_parameters = cast(

                    "_CoreMultiExecuteParams", effective_parameters

                )

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_executemany:

                        if fn(

                            cursor,

                            str_statement,

                            effective_parameters,

                            context,

                        ):

                            evt_handled = True

                            break

                if not evt_handled:

                    self.dialect.do_executemany(

                        cursor,

                        str_statement,

                        effective_parameters,

                        context,

                    )

            elif not effective_parameters and context.no_parameters:

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_execute_no_params:

                        if fn(cursor, str_statement, context):

                            evt_handled = True

                            break

                if not evt_handled:

                    self.dialect.do_execute_no_params(

                        cursor, str_statement, context

                    )

            else:

                effective_parameters = cast(

                    "_CoreSingleExecuteParams", effective_parameters

                )

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_execute:

                        if fn(

                            cursor,

                            str_statement,

                            effective_parameters,

                            context,

                        ):

                            evt_handled = True

                            break

                if not evt_handled:

>                   self.dialect.do_execute(

                        cursor, str_statement, effective_parameters, context

                    )



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1967: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:951: in do_execute

    cursor.execute(statement, parameters)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:153: in execute

    result = self._query(query)

             ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:322: in _query

    conn.query(q)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:575: in query

    self._affected_rows = self._read_query_result(unbuffered=unbuffered)

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:826: in _read_query_result

    result.read()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1203: in read

    first_packet = self.connection._read_packet()

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:782: in _read_packet

    packet.raise_for_error()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\protocol.py:219: in raise_for_error

    err.raise_mysql_exception(self._data)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



data = b"\xff&\x04#23000Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'"



    def raise_mysql_exception(data):

        errno = struct.unpack("<h", data[1:3])[0]

        # https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html

        # Error packet has optional sqlstate that is 5 bytes and starts with '#'.

        if data[3] == 0x23:  # '#'

            # sqlstate = data[4:9].decode()

            # TODO: Append (sqlstate) in the error message. This will be come in next minor release.

            errval = data[9:].decode("utf-8", "replace")

        else:

            errval = data[3:].decode("utf-8", "replace")

        errorclass = error_map.get(errno)

        if errorclass is None:

            errorclass = InternalError if errno < 1000 else OperationalError

>       raise errorclass(errno, errval)

E       pymysql.err.IntegrityError: (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\err.py:150: IntegrityError



The above exception was the direct cause of the following exception:



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

        dest_path = dest_dir / candidate

    

        # write bytes

        try:

            with dest_path.open("wb") as f:

                f.write(wm_bytes)

        except Exception as e:

            app.logger.error(

                "Failed to write watermarked file %s for document %s: %s",

                dest_path,

                doc_id,

                e,

            )

            return jsonify({"error": "failed to write watermarked file"}), 500

    

        # link token = sha256(watermarked_file_name) - using stronger hash

        link_token = hashlib.sha256(candidate.encode("utf-8")).hexdigest()

    

        try:

            with get_engine().begin() as conn:

>               conn.execute(

                    text(

                        """

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (:documentid, :link, :intended_for, :secret,

                               :method, :position, :path)

                    """

                    ),

                    {

                        "documentid": doc_id,

                        "link": link_token,

                        "intended_for": intended_for,

                        "secret": secret,

                        "method": method,

                        "position": position or "",

                        "path": str(dest_path),

                    },

                )



server.py:1069: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1419: in execute

    return meth(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\sql\elements.py:526: in _execute_on_connection

    return connection._execute_clauseelement(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1641: in _execute_clauseelement

    ret = self._execute_context(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1846: in _execute_context

    return self._exec_single_context(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1986: in _exec_single_context

    self._handle_dbapi_exception(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:2355: in _handle_dbapi_exception

    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1967: in _exec_single_context

    self.dialect.do_execute(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:951: in do_execute

    cursor.execute(statement, parameters)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:153: in execute

    result = self._query(query)

             ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:322: in _query

    conn.query(q)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:575: in query

    self._affected_rows = self._read_query_result(unbuffered=unbuffered)

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:826: in _read_query_result

    result.read()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1203: in read

    first_packet = self.connection._read_packet()

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:782: in _read_packet

    packet.raise_for_error()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\protocol.py:219: in raise_for_error

    err.raise_mysql_exception(self._data)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



data = b"\xff&\x04#23000Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'"



    def raise_mysql_exception(data):

        errno = struct.unpack("<h", data[1:3])[0]

        # https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html

        # Error packet has optional sqlstate that is 5 bytes and starts with '#'.

        if data[3] == 0x23:  # '#'

            # sqlstate = data[4:9].decode()

            # TODO: Append (sqlstate) in the error message. This will be come in next minor release.

            errval = data[9:].decode("utf-8", "replace")

        else:

            errval = data[3:].decode("utf-8", "replace")

        errorclass = error_map.get(errno)

        if errorclass is None:

            errorclass = InternalError if errno < 1000 else OperationalError

>       raise errorclass(errno, errval)

E       sqlalchemy.exc.IntegrityError: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

E       [SQL: 

E                               INSERT INTO Versions (documentid, link, intended_for,

E                                                   secret, method, position, path)

E                               VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

E                                      %(method)s, %(position)s, %(path)s)

E                           ]

E       [parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

E       (Background on this error at: https://sqlalche.me/e/20/gkpj)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\err.py:150: IntegrityError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:341: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark  bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

        dest_path = dest_dir / candidate

    

        # write bytes

        try:

            with dest_path.open("wb") as f:

                f.write(wm_bytes)

        except Exception as e:

            app.logger.error(

                "Failed to write watermarked file %s for document %s: %s",

                dest_path,

                doc_id,

                e,

            )

            return jsonify({"error": "failed to write watermarked file"}), 500

    

        # link token = sha256(watermarked_file_name) - using stronger hash

        link_token = hashlib.sha256(candidate.encode("utf-8")).hexdigest()

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (:documentid, :link, :intended_for, :secret,

                               :method, :position, :path)

                    """

                    ),

                    {

                        "documentid": doc_id,

                        "link": link_token,

                        "intended_for": intended_for,

                        "secret": secret,

                        "method": method,

                        "position": position or "",

                        "path": str(dest_path),

                    },

                )

                vid = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

>       except CosmicRayTestingException as ie:

               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       NameError: name 'CosmicRayTestingException' is not defined



server.py:1089: NameError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - NameError: name 'Co...

1 failed, 13 passed, 22 warnings in 21.07s

operator: core/ExceptionReplacer, occurrence: 48
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1090,7 +1090,7 @@
             # This should be very rare due to SHA-256 usage, but handle it just in case
             try:
                 dest_path.unlink(missing_ok=True)
-            except Exception as cleanup_error:
+            except CosmicRayTestingException as cleanup_error:
                 app.logger.warning(
                     f"Failed to cleanup file {dest_path}: {cleanup_error}"
                 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.32s

operator: core/ExceptionReplacer, occurrence: 49
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1099,7 +1099,7 @@
             )
             inc_db_error("insert_version")
             return jsonify({"error": "database error during version insert"}), 503
-        except Exception:
+        except CosmicRayTestingException:
             try:
                 dest_path.unlink(missing_ok=True)
             except Exception as cleanup_error:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.47s

operator: core/ExceptionReplacer, occurrence: 50
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1102,7 +1102,7 @@
         except Exception:
             try:
                 dest_path.unlink(missing_ok=True)
-            except Exception as cleanup_error:
+            except CosmicRayTestingException as cleanup_error:
                 app.logger.warning(
                     f"Failed to cleanup file {dest_path}: {cleanup_error}"
                 )
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e3539ebb89404f67f: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 22.50s

operator: core/ExceptionReplacer, occurrence: 51
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1153,7 +1153,7 @@
             )
         try:
             doc_id = document_id
-        except (TypeError, ValueError):
+        except (CosmicRayTestingException, ValueError):
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T004023041351Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T004023950110Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.27s

operator: core/ExceptionReplacer, occurrence: 52
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1153,7 +1153,7 @@
             )
         try:
             doc_id = document_id
-        except (TypeError, ValueError):
+        except (TypeError, CosmicRayTestingException):
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e02b77c873b6f7c77: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.69s

operator: core/ExceptionReplacer, occurrence: 53
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1171,7 +1171,7 @@
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
-        except (TypeError, ValueError):
+        except (CosmicRayTestingException, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
         if not method or not isinstance(method, str) or not isinstance(key, str):
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T013407801359Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T013408742024Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.49s

operator: core/ExceptionReplacer, occurrence: 54
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1171,7 +1171,7 @@
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
-        except (TypeError, ValueError):
+        except (TypeError, CosmicRayTestingException):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
         if not method or not isinstance(method, str) or not isinstance(key, str):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.35s

operator: core/ExceptionReplacer, occurrence: 55
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1192,7 +1192,7 @@
                     ),
                     {"id": doc_id, "owner": int(g.user["id"])},
                 ).first()
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error(
                 "Database error fetching document %s for watermark read: %s", doc_id, e
             )
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e826caa7c00bbc11e: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.81s

operator: core/ExceptionReplacer, occurrence: 56
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1212,7 +1212,7 @@
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
-        except ValueError:
+        except CosmicRayTestingException:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
             return jsonify({"error": "document path invalid"}), 500
         if not file_path.exists():
...F.....FFF.F                                                           [100%]
operator: core/ExceptionReplacer, occurrence: 57
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1222,7 +1222,7 @@
         secret = None
         try:
             secret = WMUtils.read_watermark(method=method, pdf=str(file_path), key=key)
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error(
                 "Error when attempting to read watermark for document %s: %s", doc_id, e
             )
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T015110997150Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T015111914604Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.33s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = ( 3**63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.64s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = ( 1**63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.....F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

5 failed, 9 passed, 22 warnings in 19.58s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2** 64) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T000749690405Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T000750583155Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.42s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2** 62) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) - 2
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.26s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) - 0
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055509820720Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055510764647Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.50s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -91,7 +91,7 @@
     def _serializer():
         return URLSafeTimedSerializer(app.config["SECRET_KEY"], salt="ljkdsad123123kjd")
 
-    def _auth_error(msg: str, code: int = 401):
+    def _auth_error(msg: str, code: int = 402):
         app.logger.warning("Auth error (%s): %s", code, msg)
         return jsonify({"error": msg}), code
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec7e9bd07c622611b: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.96s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -91,7 +91,7 @@
     def _serializer():
         return URLSafeTimedSerializer(app.config["SECRET_KEY"], salt="ljkdsad123123kjd")
 
-    def _auth_error(msg: str, code: int = 401):
+    def _auth_error(msg: str, code: int = 400):
         app.logger.warning("Auth error (%s): %s", code, msg)
         return jsonify({"error": msg}), code
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -99,7 +99,7 @@
         @wraps(f)
         def wrapper(*args, **kwargs):
             if app.config['TESTING']:
-                g.user = {"id": 1, "login": "username", "email": "user@email.se"}
+                g.user = {"id": 2, "login": "username", "email": "user@email.se"}
                 return f(*args, **kwargs)
             auth = request.headers.get("Authorization", "")
             if not auth.startswith("Bearer "):
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T195606495005Z__input.pdf user=2

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T195607669469Z__watermarked.pdf user=2

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 20.01s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -99,7 +99,7 @@
         @wraps(f)
         def wrapper(*args, **kwargs):
             if app.config['TESTING']:
-                g.user = {"id": 1, "login": "username", "email": "user@email.se"}
+                g.user = {"id": 0, "login": "username", "email": "user@email.se"}
                 return f(*args, **kwargs)
             auth = request.headers.get("Authorization", "")
             if not auth.startswith("Bearer "):
...F.FFF.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212348049909Z__input.pdf user=0

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 35 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:530 Missing user info in auth token

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212349231492Z__watermarked.pdf user=0

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 401 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

7 failed, 7 passed, 22 warnings in 20.30s

operator: core/NumberReplacer, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -104,7 +104,7 @@
             auth = request.headers.get("Authorization", "")
             if not auth.startswith("Bearer "):
                 return _auth_error("Missing or invalid Authorization header")
-            token = auth.split(" ", 1)[1].strip()
+            token = auth.split(" ", 2)[1].strip()
             try:
                 data = _serializer().loads(
                     token, max_age=app.config["TOKEN_TTL_SECONDS"]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/NumberReplacer, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -104,7 +104,7 @@
             auth = request.headers.get("Authorization", "")
             if not auth.startswith("Bearer "):
                 return _auth_error("Missing or invalid Authorization header")
-            token = auth.split(" ", 1)[1].strip()
+            token = auth.split(" ", 0)[1].strip()
             try:
                 data = _serializer().loads(
                     token, max_age=app.config["TOKEN_TTL_SECONDS"]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/NumberReplacer, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -104,7 +104,7 @@
             auth = request.headers.get("Authorization", "")
             if not auth.startswith("Bearer "):
                 return _auth_error("Missing or invalid Authorization header")
-            token = auth.split(" ", 1)[1].strip()
+            token = auth.split(" ", 1)[ 2].strip()
             try:
                 data = _serializer().loads(
                     token, max_age=app.config["TOKEN_TTL_SECONDS"]
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T230819227889Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T230820126490Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.39s

operator: core/NumberReplacer, occurrence: 13
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -104,7 +104,7 @@
             auth = request.headers.get("Authorization", "")
             if not auth.startswith("Bearer "):
                 return _auth_error("Missing or invalid Authorization header")
-            token = auth.split(" ", 1)[1].strip()
+            token = auth.split(" ", 1)[ 0].strip()
             try:
                 data = _serializer().loads(
                     token, max_age=app.config["TOKEN_TTL_SECONDS"]
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T213700146614Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T213701015355Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.36s

operator: core/NumberReplacer, occurrence: 14
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read( 1025 * 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/NumberReplacer, occurrence: 15
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read( 1023 * 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.42s

operator: core/NumberReplacer, occurrence: 16
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 * 1025), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.43s

operator: core/NumberReplacer, occurrence: 17
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 * 1023), b""):
                 h.update(chunk)
         return h.hexdigest()
 
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171501887559Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171502835134Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.47s

operator: core/NumberReplacer, occurrence: 18
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -180,7 +180,7 @@
             db_ok = False
         return jsonify(
             {"message": "The server is up and running.", "db_connected": db_ok}
-        ), 200
+        ), 201
 
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
FFFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_healthz_route ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_healthz_route(client):

        """Test the health check endpoint."""

        resp = client.get("/healthz")

    

>       assert resp.status_code == 200  # nosec B101

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:56: AssertionError

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172132491002Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172133349927Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_healthz_route - assert 201 == 200

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

11 failed, 3 passed, 22 warnings in 19.31s

operator: core/NumberReplacer, occurrence: 19
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -180,7 +180,7 @@
             db_ok = False
         return jsonify(
             {"message": "The server is up and running.", "db_connected": db_ok}
-        ), 200
+        ), 199
 
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
F.............                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_healthz_route ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_healthz_route(client):

        """Test the health check endpoint."""

        resp = client.get("/healthz")

    

>       assert resp.status_code == 200  # nosec B101

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 199 == 200

E        +  where 199 = <WrapperTestResponse streamed [199 UNKNOWN]>.status_code



..\test\test_api.py:56: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_healthz_route - assert 199 == 200

1 failed, 13 passed, 22 warnings in 20.77s

operator: core/NumberReplacer, occurrence: 20
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 321 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/NumberReplacer, occurrence: 21
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 319 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054420761243Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054421689486Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.40s

operator: core/NumberReplacer, occurrence: 22
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 or len(login) > 65:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/NumberReplacer, occurrence: 23
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 or len(login) > 63:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
...F.....FFF.F                                                           [100%]
operator: core/NumberReplacer, occurrence: 24
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -203,7 +203,7 @@
         start_db = time.time()
         if not email or not login or not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
-            return jsonify({"error": "email, login, and password are required"}), 400
+            return jsonify({"error": "email, login, and password are required"}), 401
 
         hpw = generate_password_hash(password)
 
.F............                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 201  # Endpoint should exist

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("id"), int)

        assert isinstance(resp_data.get("login"), str)

        assert isinstance(resp_data.get("email"), str)

        #check values are what we submitted

        assert resp_data.get("login") == parameters["login"]

        assert resp_data.get("email") == parameters["email"]

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/create-user",json={

                    "login": "username",

                    "password": "password",

                },  # pragma: allowlist secret

        )

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:90: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'login': 'username', 'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 401 == 400

1 failed, 13 passed, 22 warnings in 21.42s

operator: core/NumberReplacer, occurrence: 25
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -203,7 +203,7 @@
         start_db = time.time()
         if not email or not login or not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
-            return jsonify({"error": "email, login, and password are required"}), 400
+            return jsonify({"error": "email, login, and password are required"}), 399
 
         hpw = generate_password_hash(password)
 
.F............                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 201  # Endpoint should exist

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("id"), int)

        assert isinstance(resp_data.get("login"), str)

        assert isinstance(resp_data.get("email"), str)

        #check values are what we submitted

        assert resp_data.get("login") == parameters["login"]

        assert resp_data.get("email") == parameters["email"]

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/create-user",json={

                    "login": "username",

                    "password": "password",

                },  # pragma: allowlist secret

        )

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:90: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'login': 'username', 'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 399 == 400

1 failed, 13 passed, 22 warnings in 21.26s

operator: core/NumberReplacer, occurrence: 26
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -211,7 +211,7 @@
             is_valid, error_msg = validate_user_input(email, login)
             if not is_valid:
                 app.logger.warning("User input validation failed: %s", error_msg)
-                return jsonify({"error": error_msg}), 400
+                return jsonify({"error": error_msg}), 401
 
             with get_engine().begin() as conn:
                 res = conn.execute(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.04s

operator: core/NumberReplacer, occurrence: 27
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -211,7 +211,7 @@
             is_valid, error_msg = validate_user_input(email, login)
             if not is_valid:
                 app.logger.warning("User input validation failed: %s", error_msg)
-                return jsonify({"error": error_msg}), 400
+                return jsonify({"error": error_msg}), 399
 
             with get_engine().begin() as conn:
                 res = conn.execute(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/NumberReplacer, occurrence: 28
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -231,7 +231,7 @@
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
             )
-            return jsonify({"error": "email or login already exists"}), 409
+            return jsonify({"error": "email or login already exists"}), 410
         except Exception as e:
             app.logger.error("Database error in create_user: %s", e)
             return jsonify({"error": "database error"}), 503
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T205040241902Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T205041357658Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.92s

operator: core/NumberReplacer, occurrence: 29
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -231,7 +231,7 @@
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
             )
-            return jsonify({"error": "email or login already exists"}), 409
+            return jsonify({"error": "email or login already exists"}), 408
         except Exception as e:
             app.logger.error("Database error in create_user: %s", e)
             return jsonify({"error": "database error"}), 503
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.98s

operator: core/NumberReplacer, occurrence: 30
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -234,7 +234,7 @@
             return jsonify({"error": "email or login already exists"}), 409
         except Exception as e:
             app.logger.error("Database error in create_user: %s", e)
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 504
 
         return jsonify({"id": row.id, "email": row.email, "login": row.login}), 201
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e877cd61f49c030bf: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.71s

operator: core/NumberReplacer, occurrence: 31
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -234,7 +234,7 @@
             return jsonify({"error": "email or login already exists"}), 409
         except Exception as e:
             app.logger.error("Database error in create_user: %s", e)
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 502
 
         return jsonify({"id": row.id, "email": row.email, "login": row.login}), 201
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/NumberReplacer, occurrence: 32
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -236,7 +236,7 @@
             app.logger.error("Database error in create_user: %s", e)
             return jsonify({"error": "database error"}), 503
 
-        return jsonify({"id": row.id, "email": row.email, "login": row.login}), 201
+        return jsonify({"id": row.id, "email": row.email, "login": row.login}), 202
 
     # POST /api/login {login, password}
     @app.post("/api/login")
.F............                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 202 == 201

E        +  where 202 = <WrapperTestResponse 52 bytes [202 ACCEPTED]>.status_code



..\test\test_api.py:73: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 202 == 201

1 failed, 13 passed, 22 warnings in 20.39s

operator: core/NumberReplacer, occurrence: 33
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -236,7 +236,7 @@
             app.logger.error("Database error in create_user: %s", e)
             return jsonify({"error": "database error"}), 503
 
-        return jsonify({"id": row.id, "email": row.email, "login": row.login}), 201
+        return jsonify({"id": row.id, "email": row.email, "login": row.login}), 200
 
     # POST /api/login {login, password}
     @app.post("/api/login")
.F............                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 200 == 201

E        +  where 200 = <WrapperTestResponse 52 bytes [200 OK]>.status_code



..\test\test_api.py:73: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 200 == 201

1 failed, 13 passed, 22 warnings in 20.47s

operator: core/NumberReplacer, occurrence: 34
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -247,7 +247,7 @@
 
         if not email or not password:
             app.logger.warning("Missing fields in login attempt: %s", payload)
-            return jsonify({"error": "email and password are required"}), 400
+            return jsonify({"error": "email and password are required"}), 401
 
         start_db = time.time()
         try:
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("token"), str)

        assert isinstance(resp_data.get("token_type"), str)

        assert isinstance(resp_data.get("expires_in"), int)

        #check val

        assert resp_data.get("token_type") == "bearer"

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/login", json={"password": "password"})

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 401 == 400

1 failed, 13 passed, 22 warnings in 20.36s

operator: core/NumberReplacer, occurrence: 35
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -247,7 +247,7 @@
 
         if not email or not password:
             app.logger.warning("Missing fields in login attempt: %s", payload)
-            return jsonify({"error": "email and password are required"}), 400
+            return jsonify({"error": "email and password are required"}), 399
 
         start_db = time.time()
         try:
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("token"), str)

        assert isinstance(resp_data.get("token_type"), str)

        assert isinstance(resp_data.get("expires_in"), int)

        #check val

        assert resp_data.get("token_type") == "bearer"

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/login", json={"password": "password"})

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 399 == 400

1 failed, 13 passed, 22 warnings in 20.36s

operator: core/NumberReplacer, occurrence: 36
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -274,7 +274,7 @@
                         email if email else "<empty>",
                     )
                     inc_login_failure("invalid_credentials")
-                    return jsonify({"error": "invalid credentials"}), 401
+                    return jsonify({"error": "invalid credentials"}), 402
 
         except Exception as e:
             app.logger.error("Database error in login: %s", e)
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.32s

operator: core/NumberReplacer, occurrence: 37
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -274,7 +274,7 @@
                         email if email else "<empty>",
                     )
                     inc_login_failure("invalid_credentials")
-                    return jsonify({"error": "invalid credentials"}), 401
+                    return jsonify({"error": "invalid credentials"}), 400
 
         except Exception as e:
             app.logger.error("Database error in login: %s", e)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/NumberReplacer, occurrence: 38
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -279,7 +279,7 @@
         except Exception as e:
             app.logger.error("Database error in login: %s", e)
             inc_db_error("login_select")
-            return jsonify({"error": "An error occurred"}), 503
+            return jsonify({"error": "An error occurred"}), 504
 
         observe_db_latency("login_select", time.time() - start_db)
         token = _serializer().dumps(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.31s

operator: core/NumberReplacer, occurrence: 39
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -279,7 +279,7 @@
         except Exception as e:
             app.logger.error("Database error in login: %s", e)
             inc_db_error("login_select")
-            return jsonify({"error": "An error occurred"}), 503
+            return jsonify({"error": "An error occurred"}), 502
 
         observe_db_latency("login_select", time.time() - start_db)
         token = _serializer().dumps(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.31s

operator: core/NumberReplacer, occurrence: 40
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -292,7 +292,7 @@
                 "token_type": "bearer",
                 "expires_in": app.config["TOKEN_TTL_SECONDS"],
             }
-        ), 200
+        ), 201
 
     # POST /api/upload-document  (multipart/form-data)
     @app.post("/api/upload-document")
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse 159 bytes [201 CREATED]>.status_code



..\test\test_api.py:117: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 201 == 200

1 failed, 13 passed, 22 warnings in 20.79s

operator: core/NumberReplacer, occurrence: 41
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -292,7 +292,7 @@
                 "token_type": "bearer",
                 "expires_in": app.config["TOKEN_TTL_SECONDS"],
             }
-        ), 200
+        ), 199
 
     # POST /api/upload-document  (multipart/form-data)
     @app.post("/api/upload-document")
..FF.....FFF.F                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

>       resp_data = resp.get_json()

                    ^^^^^^^^^^^^^^^



..\test\test_api.py:112: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\response.py:620: in get_json

    return self.json_module.loads(data)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\json\provider.py:187: in loads

    return json.loads(s, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\__init__.py:346: in loads

    return _default_decoder.decode(s)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:337: in decode

    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <json.decoder.JSONDecoder object at 0x0000023C1B1148C0>, s = '', idx = 0



    def raw_decode(self, s, idx=0):

        """Decode a JSON document from ``s`` (a ``str`` beginning with

        a JSON document) and return a 2-tuple of the Python

        representation and the index in ``s`` where the document ended.

    

        This can be used to decode a JSON document from a string that may

        have extraneous data at the end.

    

        """

        try:

            obj, end = self.scan_once(s, idx)

        except StopIteration as err:

>           raise JSONDecodeError("Expecting value", s, err.value) from None

E           json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:355: JSONDecodeError

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ed0187df42caebe98: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - json.decoder.JSONDecodeError: ...

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

6 failed, 8 passed, 22 warnings in 21.19s

operator: core/NumberReplacer, occurrence: 42
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -301,7 +301,7 @@
         if "file" not in request.files:
             inc_suspicious("upload_missing_file_field")
             app.logger.warning("Upload attempt missing 'file' field")
-            return jsonify({"error": "file is required (multipart/form-data)"}), 400
+            return jsonify({"error": "file is required (multipart/form-data)"}), 401
 
         file = request.files["file"]
         if not file or file.filename == "":
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:165: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 401 == 400

1 failed, 13 passed, 22 warnings in 20.30s

operator: core/NumberReplacer, occurrence: 43
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -301,7 +301,7 @@
         if "file" not in request.files:
             inc_suspicious("upload_missing_file_field")
             app.logger.warning("Upload attempt missing 'file' field")
-            return jsonify({"error": "file is required (multipart/form-data)"}), 400
+            return jsonify({"error": "file is required (multipart/form-data)"}), 399
 
         file = request.files["file"]
         if not file or file.filename == "":
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:165: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 399 == 400

1 failed, 13 passed, 22 warnings in 20.14s

operator: core/NumberReplacer, occurrence: 44
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -306,7 +306,7 @@
         file = request.files["file"]
         if not file or file.filename == "":
             app.logger.warning("Upload attempt with empty filename")
-            return jsonify({"error": "empty filename"}), 400
+            return jsonify({"error": "empty filename"}), 401
 
         start_db = time.time()
         # Validate file size
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/NumberReplacer, occurrence: 45
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -306,7 +306,7 @@
         file = request.files["file"]
         if not file or file.filename == "":
             app.logger.warning("Upload attempt with empty filename")
-            return jsonify({"error": "empty filename"}), 400
+            return jsonify({"error": "empty filename"}), 399
 
         start_db = time.time()
         # Validate file size
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.65s

operator: core/NumberReplacer, occurrence: 46
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 51 * 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F......F...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 201 == 413

E            +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:181: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

>           assert upload_resp_data.get("id") == 2

E           AssertionError: assert 3 == 2

E            +  where 3 = <built-in method get of dict object at 0x00000203CEDD0FC0>('id')

E            +    where <built-in method get of dict object at 0x00000203CEDD0FC0> = {'creation': '2025-10-16T22:21:53.957215', 'id': 3, 'name': 'Water File', 'sha256': '5FBAC867F5EFDD7B0AB5C11456B204DDD08FF8801502C93728BE3B38BFAFE80C', ...}.get



..\test\test_api.py:390: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 201 == 413

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

2 failed, 12 passed, 22 warnings in 20.49s

operator: core/NumberReplacer, occurrence: 47
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 49 * 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/NumberReplacer, occurrence: 48
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1025 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T012216549159Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T012217484452Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.37s

operator: core/NumberReplacer, occurrence: 49
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1023 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002851898070Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002852804537Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.32s

operator: core/NumberReplacer, occurrence: 50
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 * 1025  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee6edbc3f5f8f5f99: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.76s

operator: core/NumberReplacer, occurrence: 51
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 * 1023  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/NumberReplacer, occurrence: 52
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -314,7 +314,7 @@
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
-            return jsonify({"error": "file too large"}), 413
+            return jsonify({"error": "file too large"}), 414
 
         # Validate file type and MIME type
         if file.mimetype != "application/pdf":
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 414 == 413

E            +  where 414 = <WrapperTestResponse streamed [414 REQUEST URI TOO LONG]>.status_code



..\test\test_api.py:181: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

WARNING  server:server.py:316 Upload attempt with oversized file: bigfile.pdf

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 414 == 413

1 failed, 13 passed, 22 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 53
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -314,7 +314,7 @@
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
-            return jsonify({"error": "file too large"}), 413
+            return jsonify({"error": "file too large"}), 412
 
         # Validate file type and MIME type
         if file.mimetype != "application/pdf":
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 412 == 413

E            +  where 412 = <WrapperTestResponse streamed [412 PRECONDITION FAILED]>.status_code



..\test\test_api.py:181: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

WARNING  server:server.py:316 Upload attempt with oversized file: bigfile.pdf

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 412 == 413

1 failed, 13 passed, 22 warnings in 21.12s

operator: core/NumberReplacer, occurrence: 54
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -322,7 +322,7 @@
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
             )
-            return jsonify({"error": "only PDF files are allowed"}), 415
+            return jsonify({"error": "only PDF files are allowed"}), 416
         if not file.filename.lower().endswith(".pdf"):
             inc_suspicious("upload_bad_extension")
             app.logger.warning(
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            assert resp.status_code == 413

    

        #Test with type error, txt file

        resp = client.post("/api/upload-document",

                           data={'file': (BytesIO(b"example"), "test.txt", "text/plain"),

                            'name': 'file'},

                            content_type='multipart/form-data')

>       assert resp.status_code == 415

E       assert 416 == 415

E        +  where 416 = <WrapperTestResponse streamed [416 REQUESTED RANGE NOT SATISFIABLE]>.status_code



..\test\test_api.py:188: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

WARNING  server:server.py:316 Upload attempt with oversized file: bigfile.pdf

WARNING  server:server.py:322 Upload attempt with invalid MIME type: text/plain

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 416 == 415

1 failed, 13 passed, 22 warnings in 20.55s

operator: core/NumberReplacer, occurrence: 55
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -322,7 +322,7 @@
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
             )
-            return jsonify({"error": "only PDF files are allowed"}), 415
+            return jsonify({"error": "only PDF files are allowed"}), 414
         if not file.filename.lower().endswith(".pdf"):
             inc_suspicious("upload_bad_extension")
             app.logger.warning(
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            assert resp.status_code == 413

    

        #Test with type error, txt file

        resp = client.post("/api/upload-document",

                           data={'file': (BytesIO(b"example"), "test.txt", "text/plain"),

                            'name': 'file'},

                            content_type='multipart/form-data')

>       assert resp.status_code == 415

E       assert 414 == 415

E        +  where 414 = <WrapperTestResponse streamed [414 REQUEST URI TOO LONG]>.status_code



..\test\test_api.py:188: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

WARNING  server:server.py:316 Upload attempt with oversized file: bigfile.pdf

WARNING  server:server.py:322 Upload attempt with invalid MIME type: text/plain

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 414 == 415

1 failed, 13 passed, 22 warnings in 20.48s

operator: core/NumberReplacer, occurrence: 56
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -328,7 +328,7 @@
             app.logger.warning(
                 "Upload attempt with invalid file extension: %s", file.filename
             )
-            return jsonify({"error": "only PDF files are allowed"}), 415
+            return jsonify({"error": "only PDF files are allowed"}), 416
 
         # Sanitize filename
         fname = secure_filename(file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.29s

operator: core/NumberReplacer, occurrence: 57
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -328,7 +328,7 @@
             app.logger.warning(
                 "Upload attempt with invalid file extension: %s", file.filename
             )
-            return jsonify({"error": "only PDF files are allowed"}), 415
+            return jsonify({"error": "only PDF files are allowed"}), 414
 
         # Sanitize filename
         fname = secure_filename(file.filename)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.85s

operator: core/NumberReplacer, occurrence: 58
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -336,7 +336,7 @@
             app.logger.warning(
                 "Upload attempt with invalid filename: %s", file.filename
             )
-            return jsonify({"error": "invalid filename"}), 400
+            return jsonify({"error": "invalid filename"}), 401
 
         user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T211920110409Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T211921047035Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.39s

operator: core/NumberReplacer, occurrence: 59
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -336,7 +336,7 @@
             app.logger.warning(
                 "Upload attempt with invalid filename: %s", file.filename
             )
-            return jsonify({"error": "invalid filename"}), 400
+            return jsonify({"error": "invalid filename"}), 399
 
         user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T153223671244Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T153224599563Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.50s

operator: core/NumberReplacer, occurrence: 60
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -350,7 +350,7 @@
             stored_path = (user_dir / stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
-                return jsonify({"error": "invalid path"}), 400
+                return jsonify({"error": "invalid path"}), 401
 
             file.save(stored_path)
         except Exception as e:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.55s

operator: core/NumberReplacer, occurrence: 61
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -350,7 +350,7 @@
             stored_path = (user_dir / stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
-                return jsonify({"error": "invalid path"}), 400
+                return jsonify({"error": "invalid path"}), 399
 
             file.save(stored_path)
         except Exception as e:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e0f8995d44a152f07: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.74s

operator: core/NumberReplacer, occurrence: 62
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -355,7 +355,7 @@
             file.save(stored_path)
         except Exception as e:
             app.logger.error("File save error: %s", e)
-            return jsonify({"error": "failed to save file"}), 500
+            return jsonify({"error": "failed to save file"}), 501
 
         sha_hex = _sha256_file(stored_path)
         size = stored_path.stat().st_size
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.45s

operator: core/NumberReplacer, occurrence: 63
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -355,7 +355,7 @@
             file.save(stored_path)
         except Exception as e:
             app.logger.error("File save error: %s", e)
-            return jsonify({"error": "failed to save file"}), 500
+            return jsonify({"error": "failed to save file"}), 499
 
         sha_hex = _sha256_file(stored_path)
         size = stored_path.stat().st_size
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151346271973Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151347120197Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.31s

operator: core/NumberReplacer, occurrence: 64
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -396,7 +396,7 @@
                 int(g.user["id"]),
             )
             inc_db_error("insert_document")
-            return jsonify({"error": "database error occurred"}), 503
+            return jsonify({"error": "database error occurred"}), 504
 
         observe_db_latency("insert_document", time.time() - start_db)
         resp_data = {
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 504 == 201

E            +  where 504 = <WrapperTestResponse 36 bytes [504 GATEWAY TIMEOUT]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010807341417Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 504 == 201

E            +  where 504 = <WrapperTestResponse 36 bytes [504 GATEWAY TIMEOUT]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010808181613Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 504 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 504 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.51s

operator: core/NumberReplacer, occurrence: 65
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -396,7 +396,7 @@
                 int(g.user["id"]),
             )
             inc_db_error("insert_document")
-            return jsonify({"error": "database error occurred"}), 503
+            return jsonify({"error": "database error occurred"}), 502
 
         observe_db_latency("insert_document", time.time() - start_db)
         resp_data = {
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/NumberReplacer, occurrence: 66
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -409,7 +409,7 @@
             "size": int(row.size),
         }
         inc_upload(int(row.size))
-        return jsonify(resp_data), 201
+        return jsonify(resp_data), 202
 
     # GET /api/list-documents
     @app.get("/api/list-documents")
...F......F...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 202 == 201

E            +  where 202 = <WrapperTestResponse 155 bytes [202 ACCEPTED]>.status_code



..\test\test_api.py:152: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 202 == 201

E            +  where 202 = <WrapperTestResponse 158 bytes [202 ACCEPTED]>.status_code



..\test\test_api.py:389: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 202 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 202 == 201

2 failed, 12 passed, 22 warnings in 20.37s

operator: core/NumberReplacer, occurrence: 67
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -409,7 +409,7 @@
             "size": int(row.size),
         }
         inc_upload(int(row.size))
-        return jsonify(resp_data), 201
+        return jsonify(resp_data), 200
 
     # GET /api/list-documents
     @app.get("/api/list-documents")
...F......F...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 200 == 201

E            +  where 200 = <WrapperTestResponse 155 bytes [200 OK]>.status_code



..\test\test_api.py:152: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 200 == 201

E            +  where 200 = <WrapperTestResponse 158 bytes [200 OK]>.status_code



..\test\test_api.py:389: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 200 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 200 == 201

2 failed, 12 passed, 22 warnings in 19.53s

operator: core/NumberReplacer, occurrence: 68
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -433,7 +433,7 @@
                 "Database error in list_documents for user=%s", g.user["id"]
             )
             inc_db_error("list_documents")
-            return jsonify({"error": "An error occurred while fetching documents"}), 503
+            return jsonify({"error": "An error occurred while fetching documents"}), 504
 
         docs = [
             {
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/NumberReplacer, occurrence: 69
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -433,7 +433,7 @@
                 "Database error in list_documents for user=%s", g.user["id"]
             )
             inc_db_error("list_documents")
-            return jsonify({"error": "An error occurred while fetching documents"}), 503
+            return jsonify({"error": "An error occurred while fetching documents"}), 502
 
         docs = [
             {
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/NumberReplacer, occurrence: 70
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -447,7 +447,7 @@
             }
             for r in rows
         ]
-        return jsonify({"documents": docs}), 200
+        return jsonify({"documents": docs}), 201
 
     # GET /api/list-versions
     @app.get("/api/list-versions")
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034525972219Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse 17 bytes [201 CREATED]>.status_code



..\test\test_api.py:198: AssertionError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034526875484Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 201 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.43s

operator: core/NumberReplacer, occurrence: 71
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -447,7 +447,7 @@
             }
             for r in rows
         ]
-        return jsonify({"documents": docs}), 200
+        return jsonify({"documents": docs}), 199
 
     # GET /api/list-versions
     @app.get("/api/list-versions")
....F.........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

>       resp_data = resp.get_json()

                    ^^^^^^^^^^^^^^^



..\test\test_api.py:195: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\response.py:620: in get_json

    return self.json_module.loads(data)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\json\provider.py:187: in loads

    return json.loads(s, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\__init__.py:346: in loads

    return _default_decoder.decode(s)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:337: in decode

    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <json.decoder.JSONDecoder object at 0x000002348424C5F0>, s = '', idx = 0



    def raw_decode(self, s, idx=0):

        """Decode a JSON document from ``s`` (a ``str`` beginning with

        a JSON document) and return a 2-tuple of the Python

        representation and the index in ``s`` where the document ended.

    

        This can be used to decode a JSON document from a string that may

        have extraneous data at the end.

    

        """

        try:

            obj, end = self.scan_once(s, idx)

        except StopIteration as err:

>           raise JSONDecodeError("Expecting value", s, err.value) from None

E           json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:355: JSONDecodeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_documents_route - json.decoder.JSONDeco...

1 failed, 13 passed, 22 warnings in 21.77s

operator: core/NumberReplacer, occurrence: 72
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 1 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.75s

operator: core/NumberReplacer, occurrence: 73
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= -1 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.97s

operator: core/NumberReplacer, occurrence: 74
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -461,7 +461,7 @@
                 document_id = int(document_id) if document_id else None
                 if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
-                    return jsonify({"error": "document id required"}), 400
+                    return jsonify({"error": "document id required"}), 401
             except (TypeError, ValueError):
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
...F.F...FFF.F                                                           [100%]
operator: core/NumberReplacer, occurrence: 75
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -461,7 +461,7 @@
                 document_id = int(document_id) if document_id else None
                 if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
-                    return jsonify({"error": "document id required"}), 400
+                    return jsonify({"error": "document id required"}), 399
             except (TypeError, ValueError):
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        #extract data

        doc_list = resp_data.get("versions")

        assert isinstance(doc_list, list)

        #cycle through each element in the list

        for elem in doc_list:

            assert isinstance(elem.get("id"), str)

            assert isinstance(elem.get("documentid"), str)

            #check the version is from the correct document

            assert elem.get("documentid") == str(parameters["documentid"])

            assert isinstance(elem.get("link"), str)

            assert isinstance(elem.get("intended_for"), str)

            assert isinstance(elem.get("secret"), str)

            assert isinstance(elem.get("method"), str)

    

        #Test with no parameters

        resp = client.get("/api/list-versions")

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:239: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 399 == 400

1 failed, 13 passed, 22 warnings in 20.80s

operator: core/NumberReplacer, occurrence: 76
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -464,7 +464,7 @@
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
                 app.logger.warning("Invalid document id in query")
-                return jsonify({"error": "document id required"}), 400
+                return jsonify({"error": "document id required"}), 401
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T000729227978Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T000730197742Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.35s

operator: core/NumberReplacer, occurrence: 77
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -464,7 +464,7 @@
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
                 app.logger.warning("Invalid document id in query")
-                return jsonify({"error": "document id required"}), 400
+                return jsonify({"error": "document id required"}), 399
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
...F.....FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

4 failed, 10 passed, 22 warnings in 21.34s

operator: core/NumberReplacer, occurrence: 78
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 1 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:220: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.58s

operator: core/NumberReplacer, occurrence: 79
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= -1 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.01s

operator: core/NumberReplacer, occurrence: 80
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -467,7 +467,7 @@
                 return jsonify({"error": "document id required"}), 400
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 401
 
         try:
             with get_engine().connect() as conn:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 23.13s

operator: core/NumberReplacer, occurrence: 81
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -467,7 +467,7 @@
                 return jsonify({"error": "document id required"}), 400
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 399
 
         try:
             with get_engine().connect() as conn:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.26s

operator: core/NumberReplacer, occurrence: 82
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -486,7 +486,7 @@
                     app.logger.warning(
                         "Document not found or access denied for id=%s", document_id
                     )
-                    return jsonify({"error": "document not found"}), 404
+                    return jsonify({"error": "document not found"}), 405
 
                 # Then fetch versions with ownership validation
                 rows = conn.execute(
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053026164838Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053027100307Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.90s

operator: core/NumberReplacer, occurrence: 83
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -486,7 +486,7 @@
                     app.logger.warning(
                         "Document not found or access denied for id=%s", document_id
                     )
-                    return jsonify({"error": "document not found"}), 404
+                    return jsonify({"error": "document not found"}), 403
 
                 # Then fetch versions with ownership validation
                 rows = conn.execute(
...F.F...FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        #extract data

        doc_list = resp_data.get("versions")

        assert isinstance(doc_list, list)

        #cycle through each element in the list

        for elem in doc_list:

            assert isinstance(elem.get("id"), str)

            assert isinstance(elem.get("documentid"), str)

            #check the version is from the correct document

            assert elem.get("documentid") == str(parameters["documentid"])

            assert isinstance(elem.get("link"), str)

            assert isinstance(elem.get("intended_for"), str)

            assert isinstance(elem.get("secret"), str)

            assert isinstance(elem.get("method"), str)

    

        #Test with no parameters

        resp = client.get("/api/list-versions")

        assert resp.status_code == 400

        #Test with json parameters

        resp = client.get("/api/list-versions", json = parameters)

        assert resp.status_code == 400

        #Test with wrong parameters (missing file)

        resp = client.get("/api/list-versions", query_string = {'documentid': 4})

>       assert resp.status_code == 404

E       assert 403 == 404

E        +  where 403 = <WrapperTestResponse streamed [403 FORBIDDEN]>.status_code



..\test\test_api.py:245: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

WARNING  server:server.py:463 Invalid document id in query

WARNING  server:server.py:486 Document not found or access denied for id=4

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ebfc2f16c61f41af3: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_list_versions_route - assert 403 == 404

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

6 failed, 8 passed, 22 warnings in 19.71s

operator: core/NumberReplacer, occurrence: 84
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -505,7 +505,7 @@
                 f"Database error in list_versions: {document_id},{g.user['id']}"
             )
             inc_db_error("list_versions")
-            return jsonify({"error": "An error occurred while fetching versions"}), 503
+            return jsonify({"error": "An error occurred while fetching versions"}), 504
 
         versions = [
             {
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.21s

operator: core/NumberReplacer, occurrence: 85
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -505,7 +505,7 @@
                 f"Database error in list_versions: {document_id},{g.user['id']}"
             )
             inc_db_error("list_versions")
-            return jsonify({"error": "An error occurred while fetching versions"}), 503
+            return jsonify({"error": "An error occurred while fetching versions"}), 502
 
         versions = [
             {
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.73s

operator: core/NumberReplacer, occurrence: 86
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -518,7 +518,7 @@
             }
             for r in rows
         ]
-        return jsonify({"versions": versions}), 200
+        return jsonify({"versions": versions}), 201
 
     # GET /api/list-all-versions
     @app.get("/api/list-all-versions")
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse 16 bytes [201 CREATED]>.status_code



..\test\test_api.py:220: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 201 == 200

1 failed, 13 passed, 22 warnings in 20.69s

operator: core/NumberReplacer, occurrence: 87
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -518,7 +518,7 @@
             }
             for r in rows
         ]
-        return jsonify({"versions": versions}), 200
+        return jsonify({"versions": versions}), 199
 
     # GET /api/list-all-versions
     @app.get("/api/list-all-versions")
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T015415827559Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T015416801494Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.65s

operator: core/NumberReplacer, occurrence: 88
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -528,7 +528,7 @@
             # Validate user data from auth token
             if not g.user or not g.user.get("id"):
                 app.logger.error("Missing user info in auth token")
-                return jsonify({"error": "Invalid authentication"}), 401
+                return jsonify({"error": "Invalid authentication"}), 402
 
             with get_engine().connect() as conn:
                 rows = conn.execute(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/NumberReplacer, occurrence: 89
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -528,7 +528,7 @@
             # Validate user data from auth token
             if not g.user or not g.user.get("id"):
                 app.logger.error("Missing user info in auth token")
-                return jsonify({"error": "Invalid authentication"}), 401
+                return jsonify({"error": "Invalid authentication"}), 400
 
             with get_engine().connect() as conn:
                 rows = conn.execute(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.45s

operator: core/NumberReplacer, occurrence: 90
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -546,7 +546,7 @@
                 ).all()
         except ValueError:
             app.logger.error("Invalid user ID in auth token")
-            return jsonify({"error": "Authentication error"}), 401
+            return jsonify({"error": "Authentication error"}), 402
         except Exception:
             app.logger.error(
                 "Database error in list_all_versions for user=%s", g.user["id"]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/NumberReplacer, occurrence: 91
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -546,7 +546,7 @@
                 ).all()
         except ValueError:
             app.logger.error("Invalid user ID in auth token")
-            return jsonify({"error": "Authentication error"}), 401
+            return jsonify({"error": "Authentication error"}), 400
         except Exception:
             app.logger.error(
                 "Database error in list_all_versions for user=%s", g.user["id"]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/NumberReplacer, occurrence: 92
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -552,7 +552,7 @@
                 "Database error in list_all_versions for user=%s", g.user["id"]
             )
             inc_db_error("list_all_versions")
-            return jsonify({"error": "An error occurred while fetching versions"}), 503
+            return jsonify({"error": "An error occurred while fetching versions"}), 504
 
         versions = [
             {
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef0706665929bfb4e: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 93
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -552,7 +552,7 @@
                 "Database error in list_all_versions for user=%s", g.user["id"]
             )
             inc_db_error("list_all_versions")
-            return jsonify({"error": "An error occurred while fetching versions"}), 503
+            return jsonify({"error": "An error occurred while fetching versions"}), 502
 
         versions = [
             {
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.75s

operator: core/NumberReplacer, occurrence: 94
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -564,7 +564,7 @@
             }
             for r in rows
         ]
-        return jsonify({"versions": versions}), 200
+        return jsonify({"versions": versions}), 201
 
     # GET /api/get-document or /api/get-document/<id>   returns the PDF (inline)
     @app.get("/api/get-document")
......F.......                                                           [100%]

================================== FAILURES ===================================

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse 16 bytes [201 CREATED]>.status_code



..\test\test_api.py:255: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 201 == 200

1 failed, 13 passed, 22 warnings in 22.10s

operator: core/NumberReplacer, occurrence: 95
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -564,7 +564,7 @@
             }
             for r in rows
         ]
-        return jsonify({"versions": versions}), 200
+        return jsonify({"versions": versions}), 199
 
     # GET /api/get-document or /api/get-document/<id>   returns the PDF (inline)
     @app.get("/api/get-document")
......F.......                                                           [100%]

================================== FAILURES ===================================

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

>       resp_data = resp.get_json()

                    ^^^^^^^^^^^^^^^



..\test\test_api.py:252: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\response.py:620: in get_json

    return self.json_module.loads(data)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\json\provider.py:187: in loads

    return json.loads(s, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\__init__.py:346: in loads

    return _default_decoder.decode(s)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:337: in decode

    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <json.decoder.JSONDecoder object at 0x000001AE876FC5F0>, s = '', idx = 0



    def raw_decode(self, s, idx=0):

        """Decode a JSON document from ``s`` (a ``str`` beginning with

        a JSON document) and return a 2-tuple of the Python

        representation and the index in ``s`` where the document ended.

    

        This can be used to decode a JSON document from a string that may

        have extraneous data at the end.

    

        """

        try:

            obj, end = self.scan_once(s, idx)

        except StopIteration as err:

>           raise JSONDecodeError("Expecting value", s, err.value) from None

E           json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:355: JSONDecodeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_all_versions_route - json.decoder.JSOND...

1 failed, 13 passed, 22 warnings in 21.07s

operator: core/NumberReplacer, occurrence: 96
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -578,7 +578,7 @@
                 document_id = int(document_id)
             except (TypeError, ValueError):
                 app.logger.warning("Invalid document id in query")
-                return jsonify({"error": "document id required"}), 400
+                return jsonify({"error": "document id required"}), 401
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
.......F......                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        #Test with no parameters

        resp = client.get("/api/get-document")

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:287: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert 401 == 400

1 failed, 13 passed, 22 warnings in 20.67s

operator: core/NumberReplacer, occurrence: 97
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -578,7 +578,7 @@
                 document_id = int(document_id)
             except (TypeError, ValueError):
                 app.logger.warning("Invalid document id in query")
-                return jsonify({"error": "document id required"}), 400
+                return jsonify({"error": "document id required"}), 399
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
.......F......                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        #Test with no parameters

        resp = client.get("/api/get-document")

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:287: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert 399 == 400

1 failed, 13 passed, 22 warnings in 20.27s

operator: core/NumberReplacer, occurrence: 98
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 1 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.......F......                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 13 passed, 22 warnings in 20.36s

operator: core/NumberReplacer, occurrence: 99
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= -1 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
...F.....FFF.F                                                           [100%]
operator: core/NumberReplacer, occurrence: 100
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -581,7 +581,7 @@
                 return jsonify({"error": "document id required"}), 400
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 401
 
         try:
             with get_engine().connect() as conn:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/NumberReplacer, occurrence: 101
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -581,7 +581,7 @@
                 return jsonify({"error": "document id required"}), 400
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 399
 
         try:
             with get_engine().connect() as conn:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.88s

operator: core/NumberReplacer, occurrence: 102
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -603,7 +603,7 @@
             inc_db_error("get_document")
             return jsonify(
                 {"error": "An error occurred while fetching the document"}
-            ), 503
+            ), 504
 
         # DonÔÇÖt leak whether a doc exists for another user
         if not row:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T194124620050Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T194125602259Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.78s

operator: core/NumberReplacer, occurrence: 103
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -603,7 +603,7 @@
             inc_db_error("get_document")
             return jsonify(
                 {"error": "An error occurred while fetching the document"}
-            ), 503
+            ), 502
 
         # DonÔÇÖt leak whether a doc exists for another user
         if not row:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.93s

operator: core/NumberReplacer, occurrence: 104
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -610,7 +610,7 @@
             app.logger.warning(
                 "Document not found or access denied for id=%s", document_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 405
 
         storage_root = app.config["STORAGE_DIR"].resolve()
         file_path = Path(row.path)
...F...F.FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        #Test with no parameters

        resp = client.get("/api/get-document")

        assert resp.status_code == 400

        #Test with json parameters

        resp = client.get("/api/get-document", json = parameters)

        assert resp.status_code == 400

        #Test with wrong parameters (missing file)

        resp = client.get("/api/get-document", query_string = {'documentid': 4})

>       assert resp.status_code == 404

E       assert 405 == 404

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:293: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

WARNING  server:server.py:580 Invalid document id in query

WARNING  server:server.py:610 Document not found or access denied for id=4

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e933464880bb593fb: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_get_document_route - assert 405 == 404

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

6 failed, 8 passed, 22 warnings in 21.56s

operator: core/NumberReplacer, occurrence: 105
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -610,7 +610,7 @@
             app.logger.warning(
                 "Document not found or access denied for id=%s", document_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 403
 
         storage_root = app.config["STORAGE_DIR"].resolve()
         file_path = Path(row.path)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161731484767Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161732379744Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.27s

operator: core/NumberReplacer, occurrence: 106
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -624,7 +624,7 @@
             app.logger.warning(
                 "Rejected document path for id %s: %s", document_id, row.path
             )
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 501
 
         if not resolved.exists():
             app.logger.error("File missing on disk for document id=%s", document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 24.08s

operator: core/NumberReplacer, occurrence: 107
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -624,7 +624,7 @@
             app.logger.warning(
                 "Rejected document path for id %s: %s", document_id, row.path
             )
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 499
 
         if not resolved.exists():
             app.logger.error("File missing on disk for document id=%s", document_id)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eb19a67a954d73da5: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.62s

operator: core/NumberReplacer, occurrence: 108
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -628,7 +628,7 @@
 
         if not resolved.exists():
             app.logger.error("File missing on disk for document id=%s", document_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 411
 
         # TOCTOU-safe open and validation
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.29s

operator: core/NumberReplacer, occurrence: 109
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -628,7 +628,7 @@
 
         if not resolved.exists():
             app.logger.error("File missing on disk for document id=%s", document_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 409
 
         # TOCTOU-safe open and validation
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.48s

operator: core/NumberReplacer, occurrence: 110
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -635,7 +635,7 @@
             f = open(resolved, "rb")
         except OSError:
             app.logger.error("File missing on disk for document id=%s", document_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 411
 
         try:
             # Quick PDF signature check
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/NumberReplacer, occurrence: 111
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -635,7 +635,7 @@
             f = open(resolved, "rb")
         except OSError:
             app.logger.error("File missing on disk for document id=%s", document_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 409
 
         try:
             # Quick PDF signature check
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e93e4c28298c531bf: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.84s

operator: core/NumberReplacer, occurrence: 112
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -639,7 +639,7 @@
 
         try:
             # Quick PDF signature check
-            head = f.read(5)
+            head = f.read( 6)
             if head != b"%PDF-":
                 f.close()
                 app.logger.warning(
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142723582449Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142724521547Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.21s

operator: core/NumberReplacer, occurrence: 113
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -639,7 +639,7 @@
 
         try:
             # Quick PDF signature check
-            head = f.read(5)
+            head = f.read( 4)
             if head != b"%PDF-":
                 f.close()
                 app.logger.warning(
.......F......                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:645 Invalid PDF signature for document id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 13 passed, 22 warnings in 20.46s

operator: core/NumberReplacer, occurrence: 114
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -645,7 +645,7 @@
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
                 )
-                return jsonify({"error": "document not available"}), 415
+                return jsonify({"error": "document not available"}), 416
 
             f.seek(0)
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e01b3ecb0b3a644f2: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.76s

operator: core/NumberReplacer, occurrence: 115
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -645,7 +645,7 @@
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
                 )
-                return jsonify({"error": "document not available"}), 415
+                return jsonify({"error": "document not available"}), 414
 
             f.seek(0)
 
...F.....F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eb84a0dd57a18b6d4: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 20.94s

operator: core/NumberReplacer, occurrence: 116
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -647,7 +647,7 @@
                 )
                 return jsonify({"error": "document not available"}), 415
 
-            f.seek(0)
+            f.seek( 1)
 
             # Prepare safe filename (preserve existing .pdf if present)
             name = (row.name or "document").strip().replace("\r", "").replace("\n", "")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.63s

operator: core/NumberReplacer, occurrence: 117
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -647,7 +647,7 @@
                 )
                 return jsonify({"error": "document not available"}), 415
 
-            f.seek(0)
+            f.seek( -1)
 
             # Prepare safe filename (preserve existing .pdf if present)
             name = (row.name or "document").strip().replace("\r", "").replace("\n", "")
.......F......                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:687 Error serving file for document id=1: [Errno 22] Invalid argument

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 13 passed, 22 warnings in 20.34s

operator: core/NumberReplacer, occurrence: 118
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -663,7 +663,7 @@
                 as_attachment=False,
                 download_name=name,
                 conditional=False,  # enables 304 if If-Modified-Since/Range handling
-                max_age=0,
+                max_age= 1,
                 last_modified=st.st_mtime,
             )
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e834953a9d6b0dfed: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.68s

operator: core/NumberReplacer, occurrence: 119
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -663,7 +663,7 @@
                 as_attachment=False,
                 download_name=name,
                 conditional=False,  # enables 304 if If-Modified-Since/Range handling
-                max_age=0,
+                max_age= -1,
                 last_modified=st.st_mtime,
             )
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231446919752Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231447812515Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.30s

operator: core/NumberReplacer, occurrence: 120
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -687,7 +687,7 @@
             app.logger.error(
                 "Error serving file for document id=%s: %s", document_id, e
             )
-            return jsonify({"error": "error serving file"}), 500
+            return jsonify({"error": "error serving file"}), 501
 
     # GET /api/get-version/<link>   returns the watermarked PDF (inline)
     @app.get("/api/get-version/<link>")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/NumberReplacer, occurrence: 121
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -687,7 +687,7 @@
             app.logger.error(
                 "Error serving file for document id=%s: %s", document_id, e
             )
-            return jsonify({"error": "error serving file"}), 500
+            return jsonify({"error": "error serving file"}), 499
 
     # GET /api/get-version/<link>   returns the watermarked PDF (inline)
     @app.get("/api/get-version/<link>")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.88s

operator: core/NumberReplacer, occurrence: 122
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -695,7 +695,7 @@
         # Accept both 32-char (RMAP session secrets) and 64-char (SHA-256 style) tokens
         if not re.fullmatch(r"[0-9a-f]{32}|[0-9a-f]{64}", link):
             app.logger.warning("Invalid version link format: %s", link)
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 405
 
         try:
             with get_engine().connect() as conn:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/NumberReplacer, occurrence: 123
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -695,7 +695,7 @@
         # Accept both 32-char (RMAP session secrets) and 64-char (SHA-256 style) tokens
         if not re.fullmatch(r"[0-9a-f]{32}|[0-9a-f]{64}", link):
             app.logger.warning("Invalid version link format: %s", link)
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 403
 
         try:
             with get_engine().connect() as conn:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035209740633Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035210647979Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.69s

operator: core/NumberReplacer, occurrence: 124
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -713,7 +713,7 @@
         except Exception as e:
             app.logger.error("Database error in get_version: %s", e)
             inc_db_error("get_version")
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 504
 
         if not row:
             app.logger.warning("Version not found for link: %s", link)
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T234114984087Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T234115873661Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.25s

operator: core/NumberReplacer, occurrence: 125
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -713,7 +713,7 @@
         except Exception as e:
             app.logger.error("Database error in get_version: %s", e)
             inc_db_error("get_version")
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 502
 
         if not row:
             app.logger.warning("Version not found for link: %s", link)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.17s

operator: core/NumberReplacer, occurrence: 126
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -717,7 +717,7 @@
 
         if not row:
             app.logger.warning("Version not found for link: %s", link)
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 405
 
         try:
             resolved = _safe_resolve_under_storage(row.path, app.config["STORAGE_DIR"])
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T203016219120Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T203017289544Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.00s

operator: core/NumberReplacer, occurrence: 127
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -717,7 +717,7 @@
 
         if not row:
             app.logger.warning("Version not found for link: %s", link)
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 403
 
         try:
             resolved = _safe_resolve_under_storage(row.path, app.config["STORAGE_DIR"])
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.06s

operator: core/NumberReplacer, occurrence: 128
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -725,7 +725,7 @@
             app.logger.warning(
                 "Rejected version path for link %s: %s (%s)", link, row.path, exc
             )
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 501
 
         if not resolved.exists():
             app.logger.error("File missing on disk for version link=%s", link)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/NumberReplacer, occurrence: 129
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -725,7 +725,7 @@
             app.logger.warning(
                 "Rejected version path for link %s: %s (%s)", link, row.path, exc
             )
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 499
 
         if not resolved.exists():
             app.logger.error("File missing on disk for version link=%s", link)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T052237987027Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T052238904531Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.61s

operator: core/NumberReplacer, occurrence: 130
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -729,7 +729,7 @@
 
         if not resolved.exists():
             app.logger.error("File missing on disk for version link=%s", link)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 411
 
         try:
             with resolved.open("rb") as fh:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.95s

operator: core/NumberReplacer, occurrence: 131
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -729,7 +729,7 @@
 
         if not resolved.exists():
             app.logger.error("File missing on disk for version link=%s", link)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 409
 
         try:
             with resolved.open("rb") as fh:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.29s

operator: core/NumberReplacer, occurrence: 132
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -733,7 +733,7 @@
 
         try:
             with resolved.open("rb") as fh:
-                header = fh.read(5)
+                header = fh.read( 6)
                 if header != b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.36s

operator: core/NumberReplacer, occurrence: 133
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -733,7 +733,7 @@
 
         try:
             with resolved.open("rb") as fh:
-                header = fh.read(5)
+                header = fh.read( 4)
                 if header != b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef5dde073ec300fba: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.65s

operator: core/NumberReplacer, occurrence: 134
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -738,7 +738,7 @@
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
-                    return jsonify({"error": "document not available"}), 415
+                    return jsonify({"error": "document not available"}), 416
                 fh.seek(0)
                 last_modified = os.fstat(fh.fileno()).st_mtime
         except OSError:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.77s

operator: core/NumberReplacer, occurrence: 135
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -738,7 +738,7 @@
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
-                    return jsonify({"error": "document not available"}), 415
+                    return jsonify({"error": "document not available"}), 414
                 fh.seek(0)
                 last_modified = os.fstat(fh.fileno()).st_mtime
         except OSError:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.24s

operator: core/NumberReplacer, occurrence: 136
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -739,7 +739,7 @@
                         "Invalid PDF signature for version link=%s", link
                     )
                     return jsonify({"error": "document not available"}), 415
-                fh.seek(0)
+                fh.seek( 1)
                 last_modified = os.fstat(fh.fileno()).st_mtime
         except OSError:
             app.logger.error("File missing on disk for version link=%s", link)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/NumberReplacer, occurrence: 137
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -739,7 +739,7 @@
                         "Invalid PDF signature for version link=%s", link
                     )
                     return jsonify({"error": "document not available"}), 415
-                fh.seek(0)
+                fh.seek( -1)
                 last_modified = os.fstat(fh.fileno()).st_mtime
         except OSError:
             app.logger.error("File missing on disk for version link=%s", link)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.66s

operator: core/NumberReplacer, occurrence: 138
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -743,7 +743,7 @@
                 last_modified = os.fstat(fh.fileno()).st_mtime
         except OSError:
             app.logger.error("File missing on disk for version link=%s", link)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 411
         except Exception as e:
             app.logger.error("Error inspecting version file for %s: %s", link, e)
             return jsonify({"error": "error serving file"}), 500
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.40s

operator: core/NumberReplacer, occurrence: 139
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -743,7 +743,7 @@
                 last_modified = os.fstat(fh.fileno()).st_mtime
         except OSError:
             app.logger.error("File missing on disk for version link=%s", link)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 409
         except Exception as e:
             app.logger.error("Error inspecting version file for %s: %s", link, e)
             return jsonify({"error": "error serving file"}), 500
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002932843237Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002933819517Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.32s

operator: core/NumberReplacer, occurrence: 140
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -746,7 +746,7 @@
             return jsonify({"error": "file missing on disk"}), 410
         except Exception as e:
             app.logger.error("Error inspecting version file for %s: %s", link, e)
-            return jsonify({"error": "error serving file"}), 500
+            return jsonify({"error": "error serving file"}), 501
 
         download_name = (
             row.link if row.link.lower().endswith(".pdf") else f"{row.link}.pdf"
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142951030580Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142952012817Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.41s

operator: core/NumberReplacer, occurrence: 141
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -746,7 +746,7 @@
             return jsonify({"error": "file missing on disk"}), 410
         except Exception as e:
             app.logger.error("Error inspecting version file for %s: %s", link, e)
-            return jsonify({"error": "error serving file"}), 500
+            return jsonify({"error": "error serving file"}), 499
 
         download_name = (
             row.link if row.link.lower().endswith(".pdf") else f"{row.link}.pdf"
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T014704300238Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T014705162601Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.28s

operator: core/NumberReplacer, occurrence: 142
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -760,7 +760,7 @@
                 as_attachment=False,
                 download_name=safe_download,
                 conditional=True,
-                max_age=0,
+                max_age= 1,
                 last_modified=last_modified,
             )
         except Exception as e:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/NumberReplacer, occurrence: 143
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -760,7 +760,7 @@
                 as_attachment=False,
                 download_name=safe_download,
                 conditional=True,
-                max_age=0,
+                max_age= -1,
                 last_modified=last_modified,
             )
         except Exception as e:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.39s

operator: core/NumberReplacer, occurrence: 144
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -765,7 +765,7 @@
             )
         except Exception as e:
             app.logger.error("Error serving version %s: %s", link, e)
-            return jsonify({"error": "error serving file"}), 500
+            return jsonify({"error": "error serving file"}), 501
 
         resp.headers["Cache-Control"] = "private, max-age=0, must-revalidate"
         resp.headers["Content-Type"] = "application/pdf"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.27s

operator: core/NumberReplacer, occurrence: 145
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -765,7 +765,7 @@
             )
         except Exception as e:
             app.logger.error("Error serving version %s: %s", link, e)
-            return jsonify({"error": "error serving file"}), 500
+            return jsonify({"error": "error serving file"}), 499
 
         resp.headers["Cache-Control"] = "private, max-age=0, must-revalidate"
         resp.headers["Content-Type"] = "application/pdf"
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161955962336Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161956856578Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.42s

operator: core/NumberReplacer, occurrence: 146
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -812,7 +812,7 @@
 
         if document_id is None:
             app.logger.warning("Document id required for deletion")
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 401
 
         try:
             doc_id = int(document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.47s

operator: core/NumberReplacer, occurrence: 147
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -812,7 +812,7 @@
 
         if document_id is None:
             app.logger.warning("Document id required for deletion")
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 399
 
         try:
             doc_id = int(document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.89s

operator: core/NumberReplacer, occurrence: 148
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -818,7 +818,7 @@
             doc_id = int(document_id)
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id for deletion: %s", document_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 401
 
         if doc_id <= 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.47s

operator: core/NumberReplacer, occurrence: 149
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -818,7 +818,7 @@
             doc_id = int(document_id)
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id for deletion: %s", document_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 399
 
         if doc_id <= 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef5b4fdf2f9352cdc: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.79s

operator: core/NumberReplacer, occurrence: 150
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 1 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...F.....FFF.F                                                           [100%]
operator: core/NumberReplacer, occurrence: 151
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= -1 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e7d4f5d2542eaa7bf: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.80s

operator: core/NumberReplacer, occurrence: 152
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -822,7 +822,7 @@
 
         if doc_id <= 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 401
 
         owner_id = int(g.user["id"])
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/NumberReplacer, occurrence: 153
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -822,7 +822,7 @@
 
         if doc_id <= 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 399
 
         owner_id = int(g.user["id"])
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e32da4c31f0d53f46: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.80s

operator: core/NumberReplacer, occurrence: 154
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -843,7 +843,7 @@
         except Exception as e:
             app.logger.error("DB delete error for doc id=%s: %s", doc_id, e)
             inc_db_error("delete_document_select")
-            return jsonify({"error": "database error during delete"}), 503
+            return jsonify({"error": "database error during delete"}), 504
 
         if not row:
             # DonÔÇÖt reveal othersÔÇÖ docsÔÇöjust say not found
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.29s

operator: core/NumberReplacer, occurrence: 155
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -843,7 +843,7 @@
         except Exception as e:
             app.logger.error("DB delete error for doc id=%s: %s", doc_id, e)
             inc_db_error("delete_document_select")
-            return jsonify({"error": "database error during delete"}), 503
+            return jsonify({"error": "database error during delete"}), 502
 
         if not row:
             # DonÔÇÖt reveal othersÔÇÖ docsÔÇöjust say not found
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e5164343dd78f126d: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.56s

operator: core/NumberReplacer, occurrence: 156
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -850,7 +850,7 @@
             app.logger.warning(
                 "Document not found or access denied for deletion id=%s", doc_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 405
 
         # Resolve and delete file (best effort)
         storage_root = Path(app.config["STORAGE_DIR"])
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201030487747Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201031392707Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.69s

operator: core/NumberReplacer, occurrence: 157
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -850,7 +850,7 @@
             app.logger.warning(
                 "Document not found or access denied for deletion id=%s", doc_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 403
 
         # Resolve and delete file (best effort)
         storage_root = Path(app.config["STORAGE_DIR"])
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 19.91s

operator: core/NumberReplacer, occurrence: 158
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -889,7 +889,7 @@
         except Exception as e:
             app.logger.error("DB delete error for doc id=%s: %s", doc_id, e)
             inc_db_error("delete_document_delete")
-            return jsonify({"error": "database error during delete"}), 503
+            return jsonify({"error": "database error during delete"}), 504
 
         return jsonify(
             {
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/NumberReplacer, occurrence: 159
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -889,7 +889,7 @@
         except Exception as e:
             app.logger.error("DB delete error for doc id=%s: %s", doc_id, e)
             inc_db_error("delete_document_delete")
-            return jsonify({"error": "database error during delete"}), 503
+            return jsonify({"error": "database error during delete"}), 502
 
         return jsonify(
             {
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ecaee91f0abfa537a: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.84s

operator: core/NumberReplacer, occurrence: 160
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -899,7 +899,7 @@
                 "file_missing": file_missing,
                 "note": delete_error,  # null/omitted if everything was fine
             }
-        ), 200
+        ), 201
 
     # POST /api/create-watermark or /api/create-watermark/<id>
     #  create watermarked pdf and returns metadata
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T202439113589Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T202440180729Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.89s

operator: core/NumberReplacer, occurrence: 161
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -899,7 +899,7 @@
                 "file_missing": file_missing,
                 "note": delete_error,  # null/omitted if everything was fine
             }
-        ), 200
+        ), 199
 
     # POST /api/create-watermark or /api/create-watermark/<id>
     #  create watermarked pdf and returns metadata
...........F..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 199 == 200

E        +  where 199 = <WrapperTestResponse streamed [199 UNKNOWN]>.status_code



..\test\test_api.py:443: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 199 == 200

1 failed, 13 passed, 22 warnings in 21.68s

operator: core/NumberReplacer, occurrence: 162
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -918,7 +918,7 @@
             doc_id = document_id
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id in query: %s", document_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 401
 
         payload = request.get_json(silent=True) or {}
         # allow a couple of aliases for convenience
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.12s

operator: core/NumberReplacer, occurrence: 163
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -918,7 +918,7 @@
             doc_id = document_id
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id in query: %s", document_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 399
 
         payload = request.get_json(silent=True) or {}
         # allow a couple of aliases for convenience
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 164
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -932,7 +932,7 @@
         try:
             if doc_id is None:
                 app.logger.warning("Missing document id in request")
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 401
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T043829918301Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T043830829121Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.74s

operator: core/NumberReplacer, occurrence: 165
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -932,7 +932,7 @@
         try:
             if doc_id is None:
                 app.logger.warning("Missing document id in request")
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 399
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:354: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 399 == 400

1 failed, 13 passed, 22 warnings in 20.47s

operator: core/NumberReplacer, occurrence: 166
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 1 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T175131746264Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T175132647029Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.31s

operator: core/NumberReplacer, occurrence: 167
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= -1 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/NumberReplacer, occurrence: 168
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -935,7 +935,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 401
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/NumberReplacer, occurrence: 169
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -935,7 +935,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 399
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.79s

operator: core/NumberReplacer, occurrence: 170
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -938,7 +938,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
-            return jsonify({"error": "document_id (int) is required"}), 400
+            return jsonify({"error": "document_id (int) is required"}), 401
         if (
             not method
             or not intended_for
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/NumberReplacer, occurrence: 171
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -938,7 +938,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
-            return jsonify({"error": "document_id (int) is required"}), 400
+            return jsonify({"error": "document_id (int) is required"}), 399
         if (
             not method
             or not intended_for
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.63s

operator: core/NumberReplacer, occurrence: 172
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -948,7 +948,7 @@
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify(
                 {"error": "method, intended_for, secret, and key are required"}
-            ), 400
+            ), 401
 
         # lookup the document; enforce ownership
         try:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T203202636036Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T203203522765Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.71s

operator: core/NumberReplacer, occurrence: 173
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -948,7 +948,7 @@
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify(
                 {"error": "method, intended_for, secret, and key are required"}
-            ), 400
+            ), 399
 
         # lookup the document; enforce ownership
         try:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:358: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 399 == 400

1 failed, 13 passed, 22 warnings in 20.11s

operator: core/NumberReplacer, occurrence: 174
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -966,7 +966,7 @@
                 ).first()
         except Exception as e:
             app.logger.error("Database error fetching document %s", e)
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 504
 
         if not row:
             app.logger.warning(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/NumberReplacer, occurrence: 175
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -966,7 +966,7 @@
                 ).first()
         except Exception as e:
             app.logger.error("Database error fetching document %s", e)
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 502
 
         if not row:
             app.logger.warning(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.94s

operator: core/NumberReplacer, occurrence: 176
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -972,7 +972,7 @@
             app.logger.warning(
                 "Document not found or access denied for watermarking id=%s", doc_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 405
 
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T144030632906Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 405 == 201

E        +  where 405 = <WrapperTestResponse 31 bytes [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T144031711451Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 405 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.95s

operator: core/NumberReplacer, occurrence: 177
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -972,7 +972,7 @@
             app.logger.warning(
                 "Document not found or access denied for watermarking id=%s", doc_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 403
 
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

>       assert resp.status_code == 404

E       assert 403 == 404

E        +  where 403 = <WrapperTestResponse streamed [403 FORBIDDEN]>.status_code



..\test\test_api.py:350: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 403 == 404

1 failed, 13 passed, 22 warnings in 20.15s

operator: core/NumberReplacer, occurrence: 178
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -984,7 +984,7 @@
             file_path.relative_to(storage_root)
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 501
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.27s

operator: core/NumberReplacer, occurrence: 179
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -984,7 +984,7 @@
             file_path.relative_to(storage_root)
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 499
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.61s

operator: core/NumberReplacer, occurrence: 180
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -987,7 +987,7 @@
             return jsonify({"error": "document path invalid"}), 500
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 411
 
         # check watermark applicability
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/NumberReplacer, occurrence: 181
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -987,7 +987,7 @@
             return jsonify({"error": "document path invalid"}), 500
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 409
 
         # check watermark applicability
         try:
...F.....FFF.F                                                           [100%]
operator: core/NumberReplacer, occurrence: 182
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1001,7 +1001,7 @@
                     method,
                     doc_id,
                 )
-                return jsonify({"error": "watermarking method not applicable"}), 400
+                return jsonify({"error": "watermarking method not applicable"}), 401
         except Exception as e:
             inc_watermark_failed(method, "applicability_exception")
             app.logger.error(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/NumberReplacer, occurrence: 183
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1001,7 +1001,7 @@
                     method,
                     doc_id,
                 )
-                return jsonify({"error": "watermarking method not applicable"}), 400
+                return jsonify({"error": "watermarking method not applicable"}), 399
         except Exception as e:
             inc_watermark_failed(method, "applicability_exception")
             app.logger.error(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/NumberReplacer, occurrence: 184
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1007,7 +1007,7 @@
             app.logger.error(
                 "Watermark applicability check failed for document %s: %s", doc_id, e
             )
-            return jsonify({"error": "watermark applicability check failed"}), 400
+            return jsonify({"error": "watermark applicability check failed"}), 401
 
         # apply watermark  bytes
         try:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:346: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 401 == 400

1 failed, 13 passed, 22 warnings in 20.57s

operator: core/NumberReplacer, occurrence: 185
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1007,7 +1007,7 @@
             app.logger.error(
                 "Watermark applicability check failed for document %s: %s", doc_id, e
             )
-            return jsonify({"error": "watermark applicability check failed"}), 400
+            return jsonify({"error": "watermark applicability check failed"}), 399
 
         # apply watermark  bytes
         try:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:346: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 399 == 400

1 failed, 13 passed, 22 warnings in 20.17s

operator: core/NumberReplacer, occurrence: 186
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 1:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/NumberReplacer, occurrence: 187
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == -1:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/NumberReplacer, occurrence: 188
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1028,7 +1028,7 @@
                     doc_id,
                     method,
                 )
-                return jsonify({"error": "watermarking produced no output"}), 500
+                return jsonify({"error": "watermarking produced no output"}), 501
         except Exception as e:
             inc_watermark_failed(method, "exception")
             app.logger.error(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.17s

operator: core/NumberReplacer, occurrence: 189
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1028,7 +1028,7 @@
                     doc_id,
                     method,
                 )
-                return jsonify({"error": "watermarking produced no output"}), 500
+                return jsonify({"error": "watermarking produced no output"}), 499
         except Exception as e:
             inc_watermark_failed(method, "exception")
             app.logger.error(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/NumberReplacer, occurrence: 190
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1037,7 +1037,7 @@
                 method,
                 e,
             )
-            return jsonify({"error": "watermarking failed"}), 500
+            return jsonify({"error": "watermarking failed"}), 501
 
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/NumberReplacer, occurrence: 191
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1037,7 +1037,7 @@
                 method,
                 e,
             )
-            return jsonify({"error": "watermarking failed"}), 500
+            return jsonify({"error": "watermarking failed"}), 499
 
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T024547761980Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T024548738664Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.50s

operator: core/NumberReplacer, occurrence: 192
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1059,7 +1059,7 @@
                 doc_id,
                 e,
             )
-            return jsonify({"error": "failed to write watermarked file"}), 500
+            return jsonify({"error": "failed to write watermarked file"}), 501
 
         # link token = sha256(watermarked_file_name) - using stronger hash
         link_token = hashlib.sha256(candidate.encode("utf-8")).hexdigest()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/NumberReplacer, occurrence: 193
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1059,7 +1059,7 @@
                 doc_id,
                 e,
             )
-            return jsonify({"error": "failed to write watermarked file"}), 500
+            return jsonify({"error": "failed to write watermarked file"}), 499
 
         # link token = sha256(watermarked_file_name) - using stronger hash
         link_token = hashlib.sha256(candidate.encode("utf-8")).hexdigest()
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T174027273183Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T174028142462Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.60s

operator: core/NumberReplacer, occurrence: 194
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1098,7 +1098,7 @@
                 "Integrity error during version insert for document %s: %s", doc_id, ie
             )
             inc_db_error("insert_version")
-            return jsonify({"error": "database error during version insert"}), 503
+            return jsonify({"error": "database error during version insert"}), 504
         except Exception:
             try:
                 dest_path.unlink(missing_ok=True)
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

>       assert resp.status_code == 503

E       assert 504 == 503

E        +  where 504 = <WrapperTestResponse streamed [504 GATEWAY TIMEOUT]>.status_code



..\test\test_api.py:342: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 504 == 503

1 failed, 13 passed, 22 warnings in 21.26s

operator: core/NumberReplacer, occurrence: 195
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1098,7 +1098,7 @@
                 "Integrity error during version insert for document %s: %s", doc_id, ie
             )
             inc_db_error("insert_version")
-            return jsonify({"error": "database error during version insert"}), 503
+            return jsonify({"error": "database error during version insert"}), 502
         except Exception:
             try:
                 dest_path.unlink(missing_ok=True)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e5f22414358e84166: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.00s

operator: core/NumberReplacer, occurrence: 196
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1110,7 +1110,7 @@
                 "Database error during version insert for document %s", doc_id
             )
             inc_db_error("insert_version")
-            return jsonify({"error": "database error during version insert"}), 503
+            return jsonify({"error": "database error during version insert"}), 504
 
         inc_watermark_created(method)
         return jsonify(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.99s

operator: core/NumberReplacer, occurrence: 197
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1110,7 +1110,7 @@
                 "Database error during version insert for document %s", doc_id
             )
             inc_db_error("insert_version")
-            return jsonify({"error": "database error during version insert"}), 503
+            return jsonify({"error": "database error during version insert"}), 502
 
         inc_watermark_created(method)
         return jsonify(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/NumberReplacer, occurrence: 198
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1124,7 +1124,7 @@
                 "filename": candidate,
                 "size": len(wm_bytes),
             }
-        ), 201
+        ), 202
 
     # GET /api/get-watermarking-methods
     #  {"methods":[{"name":..., "description":...}, ...], "count":N}
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223255420613Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223256376031Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.65s

operator: core/NumberReplacer, occurrence: 199
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1124,7 +1124,7 @@
                 "filename": candidate,
                 "size": len(wm_bytes),
             }
-        ), 201
+        ), 200
 
     # GET /api/get-watermarking-methods
     #  {"methods":[{"name":..., "description":...}, ...], "count":N}
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T014054813869Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T014055692569Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.22s

operator: core/NumberReplacer, occurrence: 200
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1137,7 +1137,7 @@
                 {"name": m, "description": WMUtils.get_method(m).get_usage()}
             )
 
-        return jsonify({"methods": methods, "count": len(methods)}), 200
+        return jsonify({"methods": methods, "count": len(methods)}), 201
 
     # POST /api/read-watermark
     @app.post("/api/read-watermark")
...F....FFFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_____________________ test_get_watermarking_methods_route _____________________



client = <FlaskClient <Flask 'server'>>



    def test_get_watermarking_methods_route(client):

        """Test get watermarking methods endpoint."""

        resp = client.get("/api/get-watermarking-methods")

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse 532 bytes [201 CREATED]>.status_code



..\test\test_api.py:301: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e3bdbc103784a3655: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_get_watermarking_methods_route - assert 201 ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

6 failed, 8 passed, 22 warnings in 19.68s

operator: core/NumberReplacer, occurrence: 201
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1137,7 +1137,7 @@
                 {"name": m, "description": WMUtils.get_method(m).get_usage()}
             )
 
-        return jsonify({"methods": methods, "count": len(methods)}), 200
+        return jsonify({"methods": methods, "count": len(methods)}), 199
 
     # POST /api/read-watermark
     @app.post("/api/read-watermark")
........F.....                                                           [100%]

================================== FAILURES ===================================

_____________________ test_get_watermarking_methods_route _____________________



client = <FlaskClient <Flask 'server'>>



    def test_get_watermarking_methods_route(client):

        """Test get watermarking methods endpoint."""

        resp = client.get("/api/get-watermarking-methods")

>       data = resp.get_json()

               ^^^^^^^^^^^^^^^



..\test\test_api.py:298: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\response.py:620: in get_json

    return self.json_module.loads(data)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\json\provider.py:187: in loads

    return json.loads(s, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\__init__.py:346: in loads

    return _default_decoder.decode(s)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:337: in decode

    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <json.decoder.JSONDecoder object at 0x0000024EB7458680>, s = '', idx = 0



    def raw_decode(self, s, idx=0):

        """Decode a JSON document from ``s`` (a ``str`` beginning with

        a JSON document) and return a 2-tuple of the Python

        representation and the index in ``s`` where the document ended.

    

        This can be used to decode a JSON document from a string that may

        have extraneous data at the end.

    

        """

        try:

            obj, end = self.scan_once(s, idx)

        except StopIteration as err:

>           raise JSONDecodeError("Expecting value", s, err.value) from None

E           json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:355: JSONDecodeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_watermarking_methods_route - json.decode...

1 failed, 13 passed, 22 warnings in 20.35s

operator: core/NumberReplacer, occurrence: 202
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1155,7 +1155,7 @@
             doc_id = document_id
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id in query: %s", document_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 401
 
         payload = request.get_json(silent=True) or {}
         # allow a couple of aliases for convenience
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.89s

operator: core/NumberReplacer, occurrence: 203
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1155,7 +1155,7 @@
             doc_id = document_id
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id in query: %s", document_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 399
 
         payload = request.get_json(silent=True) or {}
         # allow a couple of aliases for convenience
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.45s

operator: core/NumberReplacer, occurrence: 204
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1167,7 +1167,7 @@
         try:
             if doc_id is None:
                 app.logger.warning("Missing document id in request")
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 401
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T210905041869Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T210906029780Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 21.07s

operator: core/NumberReplacer, occurrence: 205
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1167,7 +1167,7 @@
         try:
             if doc_id is None:
                 app.logger.warning("Missing document id in request")
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 399
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("secret"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Non existant id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password"})

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:422: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1202 Document not found or access denied for watermark read id=8

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 399 == 400

1 failed, 13 passed, 22 warnings in 20.31s

operator: core/NumberReplacer, occurrence: 206
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 1 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.08s

operator: core/NumberReplacer, occurrence: 207
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= -1 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.65s

operator: core/NumberReplacer, occurrence: 208
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1170,7 +1170,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 401
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e00d6d9506a3bdffd: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 22.02s

operator: core/NumberReplacer, occurrence: 209
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1170,7 +1170,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 399
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.97s

operator: core/NumberReplacer, occurrence: 210
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1173,7 +1173,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
-            return jsonify({"error": "document_id (int) is required"}), 400
+            return jsonify({"error": "document_id (int) is required"}), 401
         if not method or not isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/NumberReplacer, occurrence: 211
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1173,7 +1173,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
-            return jsonify({"error": "document_id (int) is required"}), 400
+            return jsonify({"error": "document_id (int) is required"}), 399
         if not method or not isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.74s

operator: core/NumberReplacer, occurrence: 212
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1176,7 +1176,7 @@
             return jsonify({"error": "document_id (int) is required"}), 400
         if not method or not isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
-            return jsonify({"error": "method, and key are required"}), 400
+            return jsonify({"error": "method, and key are required"}), 401
 
         # lookup the document; enforce ownership
         try:
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("secret"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Non existant id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/read-watermark", json={"position": "metadata-only",

                                                        "key": "strong-password", "id": 2})

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:426: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1202 Document not found or access denied for watermark read id=8

WARNING  server:server.py:1169 Missing document id in request

WARNING  server:server.py:1178 Missing required fields for watermarking: {'id': 2, 'key': 'strong-password', 'position': 'metadata-only'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 401 == 400

1 failed, 13 passed, 22 warnings in 20.06s

operator: core/NumberReplacer, occurrence: 213
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1176,7 +1176,7 @@
             return jsonify({"error": "document_id (int) is required"}), 400
         if not method or not isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
-            return jsonify({"error": "method, and key are required"}), 400
+            return jsonify({"error": "method, and key are required"}), 399
 
         # lookup the document; enforce ownership
         try:
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("secret"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Non existant id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/read-watermark", json={"position": "metadata-only",

                                                        "key": "strong-password", "id": 2})

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:426: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1202 Document not found or access denied for watermark read id=8

WARNING  server:server.py:1169 Missing document id in request

WARNING  server:server.py:1178 Missing required fields for watermarking: {'id': 2, 'key': 'strong-password', 'position': 'metadata-only'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 399 == 400

1 failed, 13 passed, 22 warnings in 20.16s

operator: core/NumberReplacer, occurrence: 214
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1196,7 +1196,7 @@
             app.logger.error(
                 "Database error fetching document %s for watermark read: %s", doc_id, e
             )
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 504
 
         if not row:
             app.logger.warning(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/NumberReplacer, occurrence: 215
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1196,7 +1196,7 @@
             app.logger.error(
                 "Database error fetching document %s for watermark read: %s", doc_id, e
             )
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 502
 
         if not row:
             app.logger.warning(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.35s

operator: core/NumberReplacer, occurrence: 216
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1202,7 +1202,7 @@
             app.logger.warning(
                 "Document not found or access denied for watermark read id=%s", doc_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 405
 
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("secret"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Non existant id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password", "id": 8})

>       assert resp.status_code == 404

E       assert 405 == 404

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:417: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1202 Document not found or access denied for watermark read id=8

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 405 == 404

1 failed, 13 passed, 22 warnings in 19.92s

operator: core/NumberReplacer, occurrence: 217
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1202,7 +1202,7 @@
             app.logger.warning(
                 "Document not found or access denied for watermark read id=%s", doc_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 403
 
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("secret"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Non existant id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password", "id": 8})

>       assert resp.status_code == 404

E       assert 403 == 404

E        +  where 403 = <WrapperTestResponse streamed [403 FORBIDDEN]>.status_code



..\test\test_api.py:417: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1202 Document not found or access denied for watermark read id=8

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 403 == 404

1 failed, 13 passed, 22 warnings in 21.74s

operator: core/NumberReplacer, occurrence: 218
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1214,7 +1214,7 @@
             file_path.relative_to(storage_root)
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 501
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.04s

operator: core/NumberReplacer, occurrence: 219
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1214,7 +1214,7 @@
             file_path.relative_to(storage_root)
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 499
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.42s

operator: core/NumberReplacer, occurrence: 220
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1217,7 +1217,7 @@
             return jsonify({"error": "document path invalid"}), 500
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 411
 
         secret = None
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/NumberReplacer, occurrence: 221
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1217,7 +1217,7 @@
             return jsonify({"error": "document path invalid"}), 500
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 409
 
         secret = None
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/NumberReplacer, occurrence: 222
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1226,7 +1226,7 @@
             app.logger.error(
                 "Error when attempting to read watermark for document %s: %s", doc_id, e
             )
-            return jsonify({"error": "error when attempting to read watermark"}), 400
+            return jsonify({"error": "error when attempting to read watermark"}), 401
         inc_watermark_read(method)
         return jsonify(
             {
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.77s

operator: core/NumberReplacer, occurrence: 223
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1226,7 +1226,7 @@
             app.logger.error(
                 "Error when attempting to read watermark for document %s: %s", doc_id, e
             )
-            return jsonify({"error": "error when attempting to read watermark"}), 400
+            return jsonify({"error": "error when attempting to read watermark"}), 399
         inc_watermark_read(method)
         return jsonify(
             {
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.32s

operator: core/NumberReplacer, occurrence: 224
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1235,7 +1235,7 @@
                 "method": method,
                 "position": position,
             }
-        ), 201
+        ), 202
 
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 202 == 201

E        +  where 202 = <WrapperTestResponse 105 bytes [202 ACCEPTED]>.status_code



..\test\test_api.py:400: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 202 == 201

1 failed, 13 passed, 22 warnings in 20.47s

operator: core/NumberReplacer, occurrence: 225
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1235,7 +1235,7 @@
                 "method": method,
                 "position": position,
             }
-        ), 201
+        ), 200
 
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
...F......F...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 200 == 201

E        +  where 200 = <WrapperTestResponse 105 bytes [200 OK]>.status_code



..\test\test_api.py:400: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_read_watermark_route - assert 200 == 201

2 failed, 12 passed, 22 warnings in 20.32s

operator: core/NumberReplacer, occurrence: 226
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1251,7 +1251,7 @@
             app.logger.warning(
                 "Unauthorized metrics access attempt from %s", request.remote_addr
             )
-            return jsonify({"error": "not found"}), 404
+            return jsonify({"error": "not found"}), 405
         data = render_prometheus()
         return Response(data, mimetype="text/plain; version=0.0.4")
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.97s

operator: core/NumberReplacer, occurrence: 227
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1251,7 +1251,7 @@
             app.logger.warning(
                 "Unauthorized metrics access attempt from %s", request.remote_addr
             )
-            return jsonify({"error": "not found"}), 404
+            return jsonify({"error": "not found"}), 403
         data = render_prometheus()
         return Response(data, mimetype="text/plain; version=0.0.4")
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.93s

operator: core/NumberReplacer, occurrence: 228
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1262,7 +1262,7 @@
 app = create_app()
 
 if __name__ == "__main__":
-    port = int(os.environ.get("PORT", 5000))
+    port = int(os.environ.get("PORT", 5001))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
     app.run(host=host, port=port)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e21f6c510616c5d97: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.69s

operator: core/NumberReplacer, occurrence: 229
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1262,7 +1262,7 @@
 app = create_app()
 
 if __name__ == "__main__":
-    port = int(os.environ.get("PORT", 5000))
+    port = int(os.environ.get("PORT", 4999))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
     app.run(host=host, port=port)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ece8c3631c207ab58: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.69s

operator: core/RemoveDecorator, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -96,7 +96,6 @@
         return jsonify({"error": msg}), code
 
     def require_auth(f):
-        @wraps(f)
         def wrapper(*args, **kwargs):
             if app.config['TESTING']:
                 g.user = {"id": 1, "login": "username", "email": "user@email.se"}

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1261: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:414: in create_app

    @app.get("/api/list-documents")

     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\sansio\scaffold.py:362: in decorator

    self.add_url_rule(rule, endpoint, f, **options)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\sansio\scaffold.py:47: in wrapper_func

    return f(self, *args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\sansio\app.py:657: in add_url_rule

    raise AssertionError(

E   AssertionError: View function mapping is overwriting an existing endpoint function: wrapper

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T07:58:48+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T07:58:48+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T07:58:50+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T07:58:50+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - AssertionError: View function mapping is overwrit...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.26s

operator: core/RemoveDecorator, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -130,9 +130,6 @@
             for chunk in iter(lambda: f.read(1024 * 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
-
-    # --- Request instrumentation hooks ---
-    @app.before_request  # type: ignore
     def _tatou_before():
         try:  # record start for latency
             request._tatou_start = time.time()  # type: ignore[attr-defined]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/RemoveDecorator, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -147,8 +147,6 @@
                 app.logger.warning("Request size capture failed: %s", exc)
         except Exception as exc:  # pragma: no cover - defensive
             app.logger.warning("before_request instrumentation failed: %s", exc)
-
-    @app.after_request  # type: ignore
     def _tatou_after(resp):
         try:
             start = getattr(request, "_tatou_start", None)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/RemoveDecorator, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -159,10 +159,6 @@
         except Exception as exc:  # pragma: no cover - defensive
             app.logger.warning("after_request instrumentation failed: %s", exc)
         return resp
-
-    # --- Routes ---
-
-    @app.route("/<path:filename>")
     def static_files(filename):
         return app.send_static_file(filename)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.08s

operator: core/RemoveDecorator, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -165,8 +165,6 @@
     @app.route("/<path:filename>")
     def static_files(filename):
         return app.send_static_file(filename)
-
-    @app.route("/")
     def home():
         return app.send_static_file("index.html")
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/RemoveDecorator, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -169,8 +169,6 @@
     @app.route("/")
     def home():
         return app.send_static_file("index.html")
-
-    @app.get("/healthz")
     def healthz():
         try:
             with get_engine().connect() as conn:
F..F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_healthz_route ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_healthz_route(client):

        """Test the health check endpoint."""

        resp = client.get("/healthz")

    

>       assert resp.status_code == 200  # nosec B101

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:56: AssertionError

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:299: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:301 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1054 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:355 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:848 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e82182c29622f9083: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_healthz_route - assert 404 == 200

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

6 failed, 8 passed, 22 warnings in 19.84s

operator: core/RemoveDecorator, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -192,9 +192,6 @@
         if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
             return False, "Invalid login format"
         return True, ""
-
-    # POST /api/create-user {email, login, password}
-    @app.post("/api/create-user")
     def create_user():
         payload = request.get_json(silent=True) or {}
         email = (payload.get("email") or "").strip().lower()
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 405 == 201

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:73: AssertionError

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:269 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:390 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003013954623Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:483 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:607 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:969 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:390 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003014934724Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:847 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 405 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.06s

operator: core/RemoveDecorator, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -237,9 +237,6 @@
             return jsonify({"error": "database error"}), 503
 
         return jsonify({"id": row.id, "email": row.email, "login": row.login}), 201
-
-    # POST /api/login {login, password}
-    @app.post("/api/login")
     def login():
         payload = request.get_json(silent=True) or {}
         email = (payload.get("email") or "").strip()
..F...........                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:117: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 405 == 200

1 failed, 13 passed, 22 warnings in 20.17s

operator: core/RemoveDecorator, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -293,9 +293,6 @@
                 "expires_in": app.config["TOKEN_TTL_SECONDS"],
             }
         ), 200
-
-    # POST /api/upload-document  (multipart/form-data)
-    @app.post("/api/upload-document")
     @require_auth
     def upload_document():
         if "file" not in request.files:
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 405 == 201

E            +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:152: AssertionError

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:429 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:501 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:548 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:597 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:965 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 405 == 201

E            +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:389: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:841 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 405 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 405 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.58s

operator: core/RemoveDecorator, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -296,7 +296,6 @@
 
     # POST /api/upload-document  (multipart/form-data)
     @app.post("/api/upload-document")
-    @require_auth
     def upload_document():
         if "file" not in request.files:
             inc_suspicious("upload_missing_file_field")
...F.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:340: in upload_document

    user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

                                                     ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x000001FAC2989580>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:485 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:609 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:971 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:340: in upload_document

    user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

                                                     ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x000001FAC2998FB0>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:849 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - AttributeError: user

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - AttributeError: user

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 8 passed, 22 warnings in 19.33s

operator: core/RemoveDecorator, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -410,9 +410,6 @@
         }
         inc_upload(int(row.size))
         return jsonify(resp_data), 201
-
-    # GET /api/list-documents
-    @app.get("/api/list-documents")
     @require_auth
     def list_documents():
         try:
....F.........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:198: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_documents_route - assert 404 == 200

1 failed, 13 passed, 22 warnings in 21.36s

operator: core/RemoveDecorator, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -413,7 +413,6 @@
 
     # GET /api/list-documents
     @app.get("/api/list-documents")
-    @require_auth
     def list_documents():
         try:
             with get_engine().connect() as conn:
....F.........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

>       resp = client.get("/api/list-documents")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:194: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:432: in list_documents

    "Database error in list_documents for user=%s", g.user["id"]

                                                    ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x000001C00AA9E630>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_documents_route - AttributeError: user

1 failed, 13 passed, 22 warnings in 20.61s

operator: core/RemoveDecorator, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -448,9 +448,6 @@
             for r in rows
         ]
         return jsonify({"documents": docs}), 200
-
-    # GET /api/list-versions
-    @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
     def list_versions(document_id: int | None = None):
.....F........                                                           [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

1 failed, 13 passed, 22 warnings in 22.55s

operator: core/RemoveDecorator, occurrence: 13
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -451,7 +451,6 @@
 
     # GET /api/list-versions
     @app.get("/api/list-versions")
-    @app.get("/api/list-versions/<int:document_id>")
     @require_auth
     def list_versions(document_id: int | None = None):
         # Input validation
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/RemoveDecorator, occurrence: 14
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -452,7 +452,6 @@
     # GET /api/list-versions
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
-    @require_auth
     def list_versions(document_id: int | None = None):
         # Input validation
         if document_id is None:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T052054079843Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

>       resp = client.get("/api/list-versions", query_string = parameters)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:504: in list_versions

    f"Database error in list_versions: {document_id},{g.user['id']}"

                                                      ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x0000011D5BC56870>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:550 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:599 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:967 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T052055038467Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:843 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - AttributeError: user

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.43s

operator: core/RemoveDecorator, occurrence: 15
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -519,9 +519,6 @@
             for r in rows
         ]
         return jsonify({"versions": versions}), 200
-
-    # GET /api/list-all-versions
-    @app.get("/api/list-all-versions")
     @require_auth
     def list_all_versions():
         try:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T152008687031Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:255: AssertionError

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:597 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:965 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T152009526192Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:841 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.39s

operator: core/RemoveDecorator, occurrence: 16
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -522,7 +522,6 @@
 
     # GET /api/list-all-versions
     @app.get("/api/list-all-versions")
-    @require_auth
     def list_all_versions():
         try:
             # Validate user data from auth token
.FFF.FFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T165953442229Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

>       resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:251: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:551: in list_all_versions

    "Database error in list_all_versions for user=%s", g.user["id"]

                                                       ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x000001FF5217BA10>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:609 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:971 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T165954469526Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:849 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - AttributeError: user

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.53s

operator: core/RemoveDecorator, occurrence: 17
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -565,9 +565,6 @@
             for r in rows
         ]
         return jsonify({"versions": versions}), 200
-
-    # GET /api/get-document or /api/get-document/<id>   returns the PDF (inline)
-    @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
     def get_document(document_id: int | None = None):
.......F......                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 13 passed, 22 warnings in 21.66s

operator: core/RemoveDecorator, occurrence: 18
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -568,7 +568,6 @@
 
     # GET /api/get-document or /api/get-document/<id>   returns the PDF (inline)
     @app.get("/api/get-document")
-    @app.get("/api/get-document/<int:document_id>")
     @require_auth
     def get_document(document_id: int | None = None):
         # Support both path param and ?id=/ ?documentid=
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1055 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:849 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1ca1990627d9c814: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.75s

operator: core/RemoveDecorator, occurrence: 19
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -569,7 +569,6 @@
     # GET /api/get-document or /api/get-document/<id>   returns the PDF (inline)
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
-    @require_auth
     def get_document(document_id: int | None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
.......F...F..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

>       resp = client.get("/api/get-document", query_string=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:273: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:600: in get_document

    f"Database error in get_document: {document_id},{g.user['id']}"

                                                     ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x000001B415291460>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

>       resp_deletion = client.get("/api/get-document/2")

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:445: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:600: in get_document

    f"Database error in get_document: {document_id},{g.user['id']}"

                                                     ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x000001B41561BE90>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - AttributeError: user

FAILED ..\test\test_api.py::test_delete_document_route - AttributeError: user

2 failed, 12 passed, 22 warnings in 21.21s

operator: core/RemoveDecorator, occurrence: 20
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -688,9 +688,6 @@
                 "Error serving file for document id=%s: %s", document_id, e
             )
             return jsonify({"error": "error serving file"}), 500
-
-    # GET /api/get-version/<link>   returns the watermarked PDF (inline)
-    @app.get("/api/get-version/<link>")
     def get_version(link: str):
         # Accept both 32-char (RMAP session secrets) and 64-char (SHA-256 style) tokens
         if not re.fullmatch(r"[0-9a-f]{32}|[0-9a-f]{64}", link):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.00s

operator: core/RemoveDecorator, occurrence: 21
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -796,9 +796,6 @@
                     f"path {fp} escapes storage root {storage_root}"
                 ) from None
         return fp
-
-    # DELETE /api/delete-document  (and variants) POST supported for convenience
-    @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
     def delete_document(document_id: int | None = None):
...........F..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:443: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 405 == 200

1 failed, 13 passed, 22 warnings in 20.78s

operator: core/RemoveDecorator, occurrence: 22
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -799,7 +799,6 @@
 
     # DELETE /api/delete-document  (and variants) POST supported for convenience
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
-    @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
     def delete_document(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.48s

operator: core/RemoveDecorator, occurrence: 23
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -800,7 +800,6 @@
     # DELETE /api/delete-document  (and variants) POST supported for convenience
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
-    @require_auth
     def delete_document(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
...........F..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

>       resp = client.delete("/api/delete-document", json=document_id)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:440: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1177: in delete

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:826: in delete_document

    owner_id = int(g.user["id"])

                   ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x00000208EE645F70>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - AttributeError: user

1 failed, 13 passed, 22 warnings in 20.32s

operator: core/RemoveDecorator, occurrence: 24
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -900,10 +900,6 @@
                 "note": delete_error,  # null/omitted if everything was fine
             }
         ), 200
-
-    # POST /api/create-watermark or /api/create-watermark/<id>
-    #  create watermarked pdf and returns metadata
-    @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
     def create_watermark(document_id: int | None = None):
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 405 == 201

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:322: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 405 == 201

1 failed, 13 passed, 22 warnings in 20.23s

operator: core/RemoveDecorator, occurrence: 25
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -904,7 +904,6 @@
     # POST /api/create-watermark or /api/create-watermark/<id>
     #  create watermarked pdf and returns metadata
     @app.post("/api/create-watermark")
-    @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
     def create_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/RemoveDecorator, occurrence: 26
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -905,7 +905,6 @@
     #  create watermarked pdf and returns metadata
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
-    @require_auth
     def create_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:967 Database error fetching document user

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

1 failed, 13 passed, 22 warnings in 20.12s

operator: core/RemoveDecorator, occurrence: 27
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1125,10 +1125,6 @@
                 "size": len(wm_bytes),
             }
         ), 201
-
-    # GET /api/get-watermarking-methods
-    #  {"methods":[{"name":..., "description":...}, ...], "count":N}
-    @app.get("/api/get-watermarking-methods")
     def get_watermarking_methods():
         methods = []
 
.FFFFFFFFFFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T012418500445Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_____________________ test_get_watermarking_methods_route _____________________



client = <FlaskClient <Flask 'server'>>



    def test_get_watermarking_methods_route(client):

        """Test get watermarking methods endpoint."""

        resp = client.get("/api/get-watermarking-methods")

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:301: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T012419416248Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_get_watermarking_methods_route - assert 404 ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

11 failed, 3 passed, 22 warnings in 19.30s

operator: core/RemoveDecorator, occurrence: 28
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1138,9 +1138,6 @@
             )
 
         return jsonify({"methods": methods, "count": len(methods)}), 200
-
-    # POST /api/read-watermark
-    @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
     def read_watermark(document_id: int | None = None):
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 405 == 201

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:400: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 405 == 201

1 failed, 13 passed, 22 warnings in 19.83s

operator: core/RemoveDecorator, occurrence: 29
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1141,7 +1141,6 @@
 
     # POST /api/read-watermark
     @app.post("/api/read-watermark")
-    @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
     def read_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/RemoveDecorator, occurrence: 30
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1142,7 +1142,6 @@
     # POST /api/read-watermark
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
-    @require_auth
     def read_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1195 Database error fetching document 2 for watermark read: user

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

1 failed, 13 passed, 22 warnings in 20.74s

operator: core/RemoveDecorator, occurrence: 31
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1243,8 +1243,6 @@
         if provided != token_required:
             return False
         return True
-
-    @app.get("/metrics")
     def metrics():
         if not _is_authorized_metrics_request():
             # Obscure existence a bit ÔÇô return 404 instead of 403 to casual scans
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.11s

operator: core/ZeroIterationForLoop, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in []:
                 h.update(chunk)
         return h.hexdigest()
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.02s

operator: core/ZeroIterationForLoop, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1132,7 +1132,7 @@
     def get_watermarking_methods():
         methods = []
 
-        for m in WMUtils.METHODS:
+        for m in []:
             methods.append(
                 {"name": m, "description": WMUtils.get_method(m).get_usage()}
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 22.87s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) - amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) - 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.82s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) - 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.94s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) - value
 
     def render(self) -> str:
         # Prometheus histogram:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.98s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' - v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') - '"'
 
 
 _lock = Lock()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.67s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) - "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045520309391Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045521232089Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.86s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) * amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) * 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) * 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.35s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) * value
 
     def render(self) -> str:
         # Prometheus histogram:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' * v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.41s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') * '"'
 
 
 _lock = Lock()
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eb8b2875e6db2d160: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.62s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) * "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e23064893953a3842: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.68s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) / amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) / 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.04s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) / 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) / value
 
     def render(self) -> str:
         # Prometheus histogram:
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' / v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T210336732444Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T210337770025Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.82s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') / '"'
 
 
 _lock = Lock()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) / "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T173345013786Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T173345858634Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.25s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) // amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T012621142234Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T012622102598Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.34s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) // 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T235014093070Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T235014996408Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.33s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) // 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) // value
 
     def render(self) -> str:
         # Prometheus histogram:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.39s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' // v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.95s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') // '"'
 
 
 _lock = Lock()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) // "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) % amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T030248388482Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T030249331623Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.67s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) % 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T163845287218Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T163846132408Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.23s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) % 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045848483643Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045849397737Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.79s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) % value
 
     def render(self) -> str:
         # Prometheus histogram:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.49s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' % v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T164721175459Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T164722103300Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.27s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') % '"'
 
 
 _lock = Lock()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.54s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) % "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
...F.....F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec086e6e66d5fdd68: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 20.71s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) ** amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223028161495Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223028996533Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.53s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) ** 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T164904178776Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T164905061623Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.25s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) ** 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T052859855941Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T052900837216Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.00s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) ** value
 
     def render(self) -> str:
         # Prometheus histogram:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' ** v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042357492367Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042358493012Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 21.01s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') ** '"'
 
 
 _lock = Lock()
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033029383441Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033030395915Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.50s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) ** "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.08s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) >> amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..FF.....FF...                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) >> amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) >> amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',), key = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) >> amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) >> amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

4 failed, 10 passed, 22 warnings in 19.84s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) >> 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) >> 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.82s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) >> value
 
     def render(self) -> str:
         # Prometheus histogram:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for >>: 'float' and 'float'

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for >>: 'float' and 'float'

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for >>: 'float' and 'float'

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T233354793668Z__input.pdf user=1

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for >>: 'float' and 'float'

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for >>: 'float' and 'float'

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T233355768149Z__watermarked.pdf user=1

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for >>: 'float' and 'float'

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.42s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' >> v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.46s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') >> '"'
 
 
 _lock = Lock()
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T211816785125Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T211817771179Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) >> "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041150010425Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041151087129Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 21.40s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) << amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..FF.....FF...                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) << amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for <<: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) << amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for <<: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',), key = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) << amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for <<: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) << amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for <<: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

4 failed, 10 passed, 22 warnings in 21.34s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) << 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) << 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
...F.....F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e396046cc83a6fb69: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 21.33s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) << value
 
     def render(self) -> str:
         # Prometheus histogram:
.FFF.....FF...                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for <<: 'float' and 'float'

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for <<: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for <<: 'float' and 'float'

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...ogin_select',), 0.5): 1, (('login_select',), 1): 1, (('login_select',), 2.5): 1, (('login_select',), inf): 1}, sums={})

value = 0.10988640785217285, label_values = ('login_select',)

labels = ('login_select',), b = 2.5, inf_key = (('login_select',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) << value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for <<: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 1, (('insert_document',), 1): 1, (('insert_document',), 2.5): 1, (('insert_document',), inf): 1}, sums={})

value = 0.06377720832824707, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) << value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for <<: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for <<: 'float' and 'float'

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for <<: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for <<: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 2, (('insert_document',), 1): 2, (('insert_document',), 2.5): 2, (('insert_document',), inf): 2}, sums={})

value = 0.05775713920593262, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) << value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for <<: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

5 failed, 9 passed, 22 warnings in 19.78s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' << v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') << '"'
 
 
 _lock = Lock()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) << "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T051428062409Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T051429666030Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 25.34s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) | amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..FF.....FF...                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) | amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) | amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',), key = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) | amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) | amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

4 failed, 10 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) | 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) | 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.26s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) | value
 
     def render(self) -> str:
         # Prometheus histogram:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for |: 'float' and 'float'

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for |: 'float' and 'float'

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for |: 'float' and 'float'

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T044459311662Z__input.pdf user=1

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for |: 'float' and 'float'

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for |: 'float' and 'float'

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T044500546182Z__watermarked.pdf user=1

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for |: 'float' and 'float'

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 21.48s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' | v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.93s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') | '"'
 
 
 _lock = Lock()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.95s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) | "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T185358548578Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T185359544694Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.15s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) & amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..FF.....FF...                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) & amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for &: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) & amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for &: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',), key = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) & amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for &: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) & amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for &: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

4 failed, 10 passed, 22 warnings in 21.11s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) & 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.53s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) & 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 20.55s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) & value
 
     def render(self) -> str:
         # Prometheus histogram:
.FFF.....FF...                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for &: 'float' and 'float'

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for &: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for &: 'float' and 'float'

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...ogin_select',), 0.5): 1, (('login_select',), 1): 1, (('login_select',), 2.5): 1, (('login_select',), inf): 1}, sums={})

value = 0.11174178123474121, label_values = ('login_select',)

labels = ('login_select',), b = 2.5, inf_key = (('login_select',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) & value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for &: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 1, (('insert_document',), 1): 1, (('insert_document',), 2.5): 1, (('insert_document',), inf): 1}, sums={})

value = 0.04836273193359375, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) & value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for &: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for &: 'float' and 'float'

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for &: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for &: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 2, (('insert_document',), 1): 2, (('insert_document',), 2.5): 2, (('insert_document',), inf): 2}, sums={})

value = 0.05176377296447754, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) & value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for &: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

5 failed, 9 passed, 22 warnings in 19.80s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' & v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.49s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') & '"'
 
 
 _lock = Lock()
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172535442271Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172536380681Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.41s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) & "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042608192569Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042609160463Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.21s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) ^ amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..FF.....FF...                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) ^ amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for ^: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) ^ amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for ^: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',), key = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) ^ amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for ^: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) ^ amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for ^: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

4 failed, 10 passed, 22 warnings in 19.81s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) ^ 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.43s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) ^ 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) ^ value
 
     def render(self) -> str:
         # Prometheus histogram:
.FFF.....FF...                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for ^: 'float' and 'float'

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for ^: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for ^: 'float' and 'float'

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...ogin_select',), 0.5): 1, (('login_select',), 1): 1, (('login_select',), 2.5): 1, (('login_select',), inf): 1}, sums={})

value = 0.11115384101867676, label_values = ('login_select',)

labels = ('login_select',), b = 2.5, inf_key = (('login_select',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) ^ value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for ^: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 1, (('insert_document',), 1): 1, (('insert_document',), 2.5): 1, (('insert_document',), inf): 1}, sums={})

value = 0.05565619468688965, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) ^ value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for ^: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for ^: 'float' and 'float'

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ^: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for ^: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...t',), 1): 2, (('insert_document',), 2.5): 2, (('insert_document',), inf): 2, (('insert_document',), 0.05): 1}, sums={})

value = 0.04360318183898926, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) ^ value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for ^: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

5 failed, 9 passed, 22 warnings in 20.22s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' ^ v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020853003251Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020853838632Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.21s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') ^ '"'
 
 
 _lock = Lock()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.61s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) ^ "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() + self._start
         return False
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee5c7a2643dcaa8bc: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.81s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() * self._start
         return False
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.50s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() / self._start
         return False
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() // self._start
         return False
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.54s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() % self._start
         return False
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T013741309528Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T013742200840Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.38s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() ** self._start
         return False
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053738273815Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053739144596Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.49s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() >> self._start
         return False
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031539975613Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031540861662Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.26s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() << self._start
         return False
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053510971006Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053511851345Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.94s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() | self._start
         return False
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() & self._start
         return False
 
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142408053971Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142409049224Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 20.51s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() ^ self._start
         return False
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int + None) -> None:
     if size is None or size < 0:
         return
     with _lock:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ece65148554643ef7: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.38s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int - None) -> None:
     if size is None or size < 0:
         return
     with _lock:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.17s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int * None) -> None:
     if size is None or size < 0:
         return
     with _lock:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int / None) -> None:
     if size is None or size < 0:
         return
     with _lock:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e941fe79501459c6b: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.67s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int // None) -> None:
     if size is None or size < 0:
         return
     with _lock:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int % None) -> None:
     if size is None or size < 0:
         return
     with _lock:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int ** None) -> None:
     if size is None or size < 0:
         return
     with _lock:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int >> None) -> None:
     if size is None or size < 0:
         return
     with _lock:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int << None) -> None:
     if size is None or size < 0:
         return
     with _lock:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T200426505766Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T200427423347Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.68s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int & None) -> None:
     if size is None or size < 0:
         return
     with _lock:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T180850338455Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T180851249389Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.72s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int ^ None) -> None:
     if size is None or size < 0:
         return
     with _lock:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212823055200Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212823905699Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.19s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if len(label_values) == len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
..FF.....FF...                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) == len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) == len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) == len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) == len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - ValueError: Label c...

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

4 failed, 10 passed, 22 warnings in 19.95s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if len(label_values) == len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T014644077862Z__input.pdf user=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T014644986488Z__watermarked.pdf user=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.34s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if len(label_values) < len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.47s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if len(label_values) < len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033316926856Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033318235331Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.76s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if len(label_values) <= len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

______________________________ test_login_route _______________________________



self = <sqlalchemy.engine.base.Connection object at 0x0000021C80F85550>

engine = Engine(mysql+pymysql://tatou:***@127.0.0.1:3306/tatou?charset=utf8mb4)

connection = None, _has_events = None, _allow_revalidate = True

_allow_autobegin = True



    def __init__(

        self,

        engine: Engine,

        connection: Optional[PoolProxiedConnection] = None,

        _has_events: Optional[bool] = None,

        _allow_revalidate: bool = True,

        _allow_autobegin: bool = True,

    ):

        """Construct a new Connection."""

        self.engine = engine

        self.dialect = dialect = engine.dialect

    

        if connection is None:

            try:

>               self._dbapi_connection = engine.raw_connection()

                                         ^^^^^^^^^^^^^^^^^^^^^^^



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:143: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3301: in raw_connection

    return self.pool.connect()

           ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:447: in connect

    return _ConnectionFairy._checkout(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:1264: in _checkout

    fairy = _ConnectionRecord.checkout(pool)

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:711: in checkout

    rec = pool._do_get()

          ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:177: in _do_get

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:175: in _do_get

    return self._create_connection()

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:388: in _create_connection

    return _ConnectionRecord(self)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:673: in __init__

    self.__connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:899: in __connect

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:895: in __connect

    self.dbapi_connection = connection = pool._invoke_creator(self)

                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py:661: in connect

    return dialect.connect(*cargs, **cparams)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:629: in connect

    return self.loaded_dbapi.connect(*cargs, **cparams)  # type: ignore[no-any-return]  # NOQA: E501

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:365: in __init__

    self.connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:680: in connect

    self._get_server_information()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1099: in _get_server_information

    packet = self._read_packet()

             ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:751: in _read_packet

    packet_header = self._read_bytes(4)

                    ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymysql.connections.Connection object at 0x0000021C80F85AF0>

num_bytes = 4



    def _read_bytes(self, num_bytes):

        self._sock.settimeout(self._read_timeout)

        while True:

            try:

                data = self._rfile.read(num_bytes)

                break

            except OSError as e:

                if e.errno == errno.EINTR:

                    continue

                self._force_close()

                raise err.OperationalError(

                    CR.CR_SERVER_LOST,

                    f"Lost connection to MySQL server during query ({e})",

                )

            except BaseException:

                # Don't convert unknown exception to MySQLError.

                self._force_close()

                raise

        if len(data) < num_bytes:

            self._force_close()

>           raise err.OperationalError(

                CR.CR_SERVER_LOST, "Lost connection to MySQL server during query"

            )

E           pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:805: OperationalError



The above exception was the direct cause of the following exception:



    @app.post("/api/login")

    def login():

        payload = request.get_json(silent=True) or {}

        email = (payload.get("email") or "").strip()

        password = payload.get("password") or ""

    

        if not email or not password:

            app.logger.warning("Missing fields in login attempt: %s", payload)

            return jsonify({"error": "email and password are required"}), 400

    

        start_db = time.time()

        try:

>           with get_engine().connect() as conn:

                 ^^^^^^^^^^^^^^^^^^^^^^



server.py:254: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3277: in connect

    return self._connection_cls(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:145: in __init__

    Connection._handle_dbapi_exception_noconnection(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:2440: in _handle_dbapi_exception_noconnection

    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:143: in __init__

    self._dbapi_connection = engine.raw_connection()

                             ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3301: in raw_connection

    return self.pool.connect()

           ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:447: in connect

    return _ConnectionFairy._checkout(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:1264: in _checkout

    fairy = _ConnectionRecord.checkout(pool)

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:711: in checkout

    rec = pool._do_get()

          ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:177: in _do_get

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:175: in _do_get

    return self._create_connection()

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:388: in _create_connection

    return _ConnectionRecord(self)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:673: in __init__

    self.__connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:899: in __connect

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:895: in __connect

    self.dbapi_connection = connection = pool._invoke_creator(self)

                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py:661: in connect

    return dialect.connect(*cargs, **cparams)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:629: in connect

    return self.loaded_dbapi.connect(*cargs, **cparams)  # type: ignore[no-any-return]  # NOQA: E501

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:365: in __init__

    self.connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:680: in connect

    self._get_server_information()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1099: in _get_server_information

    packet = self._read_packet()

             ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:751: in _read_packet

    packet_header = self._read_bytes(4)

                    ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymysql.connections.Connection object at 0x0000021C80F85AF0>

num_bytes = 4



    def _read_bytes(self, num_bytes):

        self._sock.settimeout(self._read_timeout)

        while True:

            try:

                data = self._rfile.read(num_bytes)

                break

            except OSError as e:

                if e.errno == errno.EINTR:

                    continue

                self._force_close()

                raise err.OperationalError(

                    CR.CR_SERVER_LOST,

                    f"Lost connection to MySQL server during query ({e})",

                )

            except BaseException:

                # Don't convert unknown exception to MySQLError.

                self._force_close()

                raise

        if len(data) < num_bytes:

            self._force_close()

>           raise err.OperationalError(

                CR.CR_SERVER_LOST, "Lost connection to MySQL server during query"

            )

E           sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

E           (Background on this error at: https://sqlalche.me/e/20/e3q8)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:805: OperationalError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:281: in login

    inc_db_error("login_select")

observability.py:312: in inc_db_error

    DB_ERRORS.inc(op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_db_errors_total', help='Database operation errors', values={}, label_names=('operation',))

amount = 1.0, label_values = ('login_select',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) <= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



self = <sqlalchemy.engine.base.Connection object at 0x0000021C80E8BCE0>

engine = Engine(mysql+pymysql://tatou:***@127.0.0.1:3306/tatou?charset=utf8mb4)

connection = None, _has_events = None, _allow_revalidate = True

_allow_autobegin = True



    def __init__(

        self,

        engine: Engine,

        connection: Optional[PoolProxiedConnection] = None,

        _has_events: Optional[bool] = None,

        _allow_revalidate: bool = True,

        _allow_autobegin: bool = True,

    ):

        """Construct a new Connection."""

        self.engine = engine

        self.dialect = dialect = engine.dialect

    

        if connection is None:

            try:

>               self._dbapi_connection = engine.raw_connection()

                                         ^^^^^^^^^^^^^^^^^^^^^^^



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:143: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3301: in raw_connection

    return self.pool.connect()

           ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:447: in connect

    return _ConnectionFairy._checkout(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:1264: in _checkout

    fairy = _ConnectionRecord.checkout(pool)

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:711: in checkout

    rec = pool._do_get()

          ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:177: in _do_get

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:175: in _do_get

    return self._create_connection()

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:388: in _create_connection

    return _ConnectionRecord(self)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:673: in __init__

    self.__connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:899: in __connect

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:895: in __connect

    self.dbapi_connection = connection = pool._invoke_creator(self)

                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py:661: in connect

    return dialect.connect(*cargs, **cparams)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:629: in connect

    return self.loaded_dbapi.connect(*cargs, **cparams)  # type: ignore[no-any-return]  # NOQA: E501

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:365: in __init__

    self.connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:680: in connect

    self._get_server_information()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1099: in _get_server_information

    packet = self._read_packet()

             ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:751: in _read_packet

    packet_header = self._read_bytes(4)

                    ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymysql.connections.Connection object at 0x0000021C81702900>

num_bytes = 4



    def _read_bytes(self, num_bytes):

        self._sock.settimeout(self._read_timeout)

        while True:

            try:

                data = self._rfile.read(num_bytes)

                break

            except OSError as e:

                if e.errno == errno.EINTR:

                    continue

                self._force_close()

                raise err.OperationalError(

                    CR.CR_SERVER_LOST,

                    f"Lost connection to MySQL server during query ({e})",

                )

            except BaseException:

                # Don't convert unknown exception to MySQLError.

                self._force_close()

                raise

        if len(data) < num_bytes:

            self._force_close()

>           raise err.OperationalError(

                CR.CR_SERVER_LOST, "Lost connection to MySQL server during query"

            )

E           pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:805: OperationalError



The above exception was the direct cause of the following exception:



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

>           with get_engine().begin() as conn:



server.py:364: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\contextlib.py:137: in __enter__

    return next(self.gen)

           ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3241: in begin

    with self.connect() as conn:

         ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3277: in connect

    return self._connection_cls(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:145: in __init__

    Connection._handle_dbapi_exception_noconnection(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:2440: in _handle_dbapi_exception_noconnection

    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:143: in __init__

    self._dbapi_connection = engine.raw_connection()

                             ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3301: in raw_connection

    return self.pool.connect()

           ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:447: in connect

    return _ConnectionFairy._checkout(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:1264: in _checkout

    fairy = _ConnectionRecord.checkout(pool)

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:711: in checkout

    rec = pool._do_get()

          ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:177: in _do_get

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:175: in _do_get

    return self._create_connection()

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:388: in _create_connection

    return _ConnectionRecord(self)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:673: in __init__

    self.__connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:899: in __connect

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:895: in __connect

    self.dbapi_connection = connection = pool._invoke_creator(self)

                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py:661: in connect

    return dialect.connect(*cargs, **cparams)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:629: in connect

    return self.loaded_dbapi.connect(*cargs, **cparams)  # type: ignore[no-any-return]  # NOQA: E501

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:365: in __init__

    self.connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:680: in connect

    self._get_server_information()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1099: in _get_server_information

    packet = self._read_packet()

             ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:751: in _read_packet

    packet_header = self._read_bytes(4)

                    ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymysql.connections.Connection object at 0x0000021C81702900>

num_bytes = 4



    def _read_bytes(self, num_bytes):

        self._sock.settimeout(self._read_timeout)

        while True:

            try:

                data = self._rfile.read(num_bytes)

                break

            except OSError as e:

                if e.errno == errno.EINTR:

                    continue

                self._force_close()

                raise err.OperationalError(

                    CR.CR_SERVER_LOST,

                    f"Lost connection to MySQL server during query ({e})",

                )

            except BaseException:

                # Don't convert unknown exception to MySQLError.

                self._force_close()

                raise

        if len(data) < num_bytes:

            self._force_close()

>           raise err.OperationalError(

                CR.CR_SERVER_LOST, "Lost connection to MySQL server during query"

            )

E           sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

E           (Background on this error at: https://sqlalche.me/e/20/e3q8)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:805: OperationalError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:398: in upload_document

    inc_db_error("insert_document")

observability.py:312: in inc_db_error

    DB_ERRORS.inc(op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_db_errors_total', help='Database operation errors', values={}, label_names=('operation',))

amount = 1.0, label_values = ('insert_document',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) <= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061049427024Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



self = <sqlalchemy.engine.base.Connection object at 0x0000021C80CCC860>

engine = Engine(mysql+pymysql://tatou:***@127.0.0.1:3306/tatou?charset=utf8mb4)

connection = None, _has_events = None, _allow_revalidate = True

_allow_autobegin = True



    def __init__(

        self,

        engine: Engine,

        connection: Optional[PoolProxiedConnection] = None,

        _has_events: Optional[bool] = None,

        _allow_revalidate: bool = True,

        _allow_autobegin: bool = True,

    ):

        """Construct a new Connection."""

        self.engine = engine

        self.dialect = dialect = engine.dialect

    

        if connection is None:

            try:

>               self._dbapi_connection = engine.raw_connection()

                                         ^^^^^^^^^^^^^^^^^^^^^^^



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:143: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3301: in raw_connection

    return self.pool.connect()

           ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:447: in connect

    return _ConnectionFairy._checkout(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:1264: in _checkout

    fairy = _ConnectionRecord.checkout(pool)

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:711: in checkout

    rec = pool._do_get()

          ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:177: in _do_get

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:175: in _do_get

    return self._create_connection()

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:388: in _create_connection

    return _ConnectionRecord(self)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:673: in __init__

    self.__connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:899: in __connect

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:895: in __connect

    self.dbapi_connection = connection = pool._invoke_creator(self)

                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py:661: in connect

    return dialect.connect(*cargs, **cparams)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:629: in connect

    return self.loaded_dbapi.connect(*cargs, **cparams)  # type: ignore[no-any-return]  # NOQA: E501

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:365: in __init__

    self.connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:680: in connect

    self._get_server_information()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1099: in _get_server_information

    packet = self._read_packet()

             ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:751: in _read_packet

    packet_header = self._read_bytes(4)

                    ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymysql.connections.Connection object at 0x0000021C80CCCDA0>

num_bytes = 4



    def _read_bytes(self, num_bytes):

        self._sock.settimeout(self._read_timeout)

        while True:

            try:

                data = self._rfile.read(num_bytes)

                break

            except OSError as e:

                if e.errno == errno.EINTR:

                    continue

                self._force_close()

                raise err.OperationalError(

                    CR.CR_SERVER_LOST,

                    f"Lost connection to MySQL server during query ({e})",

                )

            except BaseException:

                # Don't convert unknown exception to MySQLError.

                self._force_close()

                raise

        if len(data) < num_bytes:

            self._force_close()

>           raise err.OperationalError(

                CR.CR_SERVER_LOST, "Lost connection to MySQL server during query"

            )

E           pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:805: OperationalError



The above exception was the direct cause of the following exception:



    @app.get("/api/list-documents")

    @require_auth

    def list_documents():

        try:

>           with get_engine().connect() as conn:

                 ^^^^^^^^^^^^^^^^^^^^^^



server.py:419: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3277: in connect

    return self._connection_cls(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:145: in __init__

    Connection._handle_dbapi_exception_noconnection(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:2440: in _handle_dbapi_exception_noconnection

    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:143: in __init__

    self._dbapi_connection = engine.raw_connection()

                             ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3301: in raw_connection

    return self.pool.connect()

           ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:447: in connect

    return _ConnectionFairy._checkout(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:1264: in _checkout

    fairy = _ConnectionRecord.checkout(pool)

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:711: in checkout

    rec = pool._do_get()

          ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:177: in _do_get

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:175: in _do_get

    return self._create_connection()

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:388: in _create_connection

    return _ConnectionRecord(self)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:673: in __init__

    self.__connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:899: in __connect

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:895: in __connect

    self.dbapi_connection = connection = pool._invoke_creator(self)

                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py:661: in connect

    return dialect.connect(*cargs, **cparams)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:629: in connect

    return self.loaded_dbapi.connect(*cargs, **cparams)  # type: ignore[no-any-return]  # NOQA: E501

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:365: in __init__

    self.connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:680: in connect

    self._get_server_information()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1099: in _get_server_information

    packet = self._read_packet()

             ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:751: in _read_packet

    packet_header = self._read_bytes(4)

                    ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymysql.connections.Connection object at 0x0000021C80CCCDA0>

num_bytes = 4



    def _read_bytes(self, num_bytes):

        self._sock.settimeout(self._read_timeout)

        while True:

            try:

                data = self._rfile.read(num_bytes)

                break

            except OSError as e:

                if e.errno == errno.EINTR:

                    continue

                self._force_close()

                raise err.OperationalError(

                    CR.CR_SERVER_LOST,

                    f"Lost connection to MySQL server during query ({e})",

                )

            except BaseException:

                # Don't convert unknown exception to MySQLError.

                self._force_close()

                raise

        if len(data) < num_bytes:

            self._force_close()

>           raise err.OperationalError(

                CR.CR_SERVER_LOST, "Lost connection to MySQL server during query"

            )

E           sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

E           (Background on this error at: https://sqlalche.me/e/20/e3q8)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:805: OperationalError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

>       resp = client.get("/api/list-documents")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:194: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:435: in list_documents

    inc_db_error("list_documents")

observability.py:312: in inc_db_error

    DB_ERRORS.inc(op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_db_errors_total', help='Database operation errors', values={}, label_names=('operation',))

amount = 1.0, label_values = ('list_documents',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) <= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



self = <sqlalchemy.engine.base.Connection object at 0x0000021C8101E480>

engine = Engine(mysql+pymysql://tatou:***@127.0.0.1:3306/tatou?charset=utf8mb4)

connection = None, _has_events = None, _allow_revalidate = True

_allow_autobegin = True



    def __init__(

        self,

        engine: Engine,

        connection: Optional[PoolProxiedConnection] = None,

        _has_events: Optional[bool] = None,

        _allow_revalidate: bool = True,

        _allow_autobegin: bool = True,

    ):

        """Construct a new Connection."""

        self.engine = engine

        self.dialect = dialect = engine.dialect

    

        if connection is None:

            try:

>               self._dbapi_connection = engine.raw_connection()

                                         ^^^^^^^^^^^^^^^^^^^^^^^



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:143: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3301: in raw_connection

    return self.pool.connect()

           ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:447: in connect

    return _ConnectionFairy._checkout(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:1264: in _checkout

    fairy = _ConnectionRecord.checkout(pool)

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:711: in checkout

    rec = pool._do_get()

          ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:177: in _do_get

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:175: in _do_get

    return self._create_connection()

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:388: in _create_connection

    return _ConnectionRecord(self)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:673: in __init__

    self.__connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:899: in __connect

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:895: in __connect

    self.dbapi_connection = connection = pool._invoke_creator(self)

                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py:661: in connect

    return dialect.connect(*cargs, **cparams)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:629: in connect

    return self.loaded_dbapi.connect(*cargs, **cparams)  # type: ignore[no-any-return]  # NOQA: E501

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:365: in __init__

    self.connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:680: in connect

    self._get_server_information()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1099: in _get_server_information

    packet = self._read_packet()

             ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:751: in _read_packet

    packet_header = self._read_bytes(4)

                    ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymysql.connections.Connection object at 0x0000021C80FDCC50>

num_bytes = 4



    def _read_bytes(self, num_bytes):

        self._sock.settimeout(self._read_timeout)

        while True:

            try:

                data = self._rfile.read(num_bytes)

                break

            except OSError as e:

                if e.errno == errno.EINTR:

                    continue

                self._force_close()

                raise err.OperationalError(

                    CR.CR_SERVER_LOST,

                    f"Lost connection to MySQL server during query ({e})",

                )

            except BaseException:

                # Don't convert unknown exception to MySQLError.

                self._force_close()

                raise

        if len(data) < num_bytes:

            self._force_close()

>           raise err.OperationalError(

                CR.CR_SERVER_LOST, "Lost connection to MySQL server during query"

            )

E           pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:805: OperationalError



The above exception was the direct cause of the following exception:



document_id = 1



    @app.get("/api/list-versions")

    @app.get("/api/list-versions/<int:document_id>")

    @require_auth

    def list_versions(document_id: int | None = None):

        # Input validation

        if document_id is None:

            document_id = request.args.get("id") or request.args.get("documentid")

            try:

                document_id = int(document_id) if document_id else None

                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:

                    app.logger.warning("Invalid document id in query")

                    return jsonify({"error": "document id required"}), 400

            except (TypeError, ValueError):

                app.logger.warning("Invalid document id in query")

                return jsonify({"error": "document id required"}), 400

    

        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:

            return jsonify({"error": "document id required"}), 400

    

        try:

>           with get_engine().connect() as conn:

                 ^^^^^^^^^^^^^^^^^^^^^^



server.py:473: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3277: in connect

    return self._connection_cls(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:145: in __init__

    Connection._handle_dbapi_exception_noconnection(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:2440: in _handle_dbapi_exception_noconnection

    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:143: in __init__

    self._dbapi_connection = engine.raw_connection()

                             ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3301: in raw_connection

    return self.pool.connect()

           ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:447: in connect

    return _ConnectionFairy._checkout(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:1264: in _checkout

    fairy = _ConnectionRecord.checkout(pool)

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:711: in checkout

    rec = pool._do_get()

          ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:177: in _do_get

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:175: in _do_get

    return self._create_connection()

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:388: in _create_connection

    return _ConnectionRecord(self)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:673: in __init__

    self.__connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:899: in __connect

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:895: in __connect

    self.dbapi_connection = connection = pool._invoke_creator(self)

                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py:661: in connect

    return dialect.connect(*cargs, **cparams)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:629: in connect

    return self.loaded_dbapi.connect(*cargs, **cparams)  # type: ignore[no-any-return]  # NOQA: E501

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:365: in __init__

    self.connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:680: in connect

    self._get_server_information()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1099: in _get_server_information

    packet = self._read_packet()

             ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:751: in _read_packet

    packet_header = self._read_bytes(4)

                    ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymysql.connections.Connection object at 0x0000021C80FDCC50>

num_bytes = 4



    def _read_bytes(self, num_bytes):

        self._sock.settimeout(self._read_timeout)

        while True:

            try:

                data = self._rfile.read(num_bytes)

                break

            except OSError as e:

                if e.errno == errno.EINTR:

                    continue

                self._force_close()

                raise err.OperationalError(

                    CR.CR_SERVER_LOST,

                    f"Lost connection to MySQL server during query ({e})",

                )

            except BaseException:

                # Don't convert unknown exception to MySQLError.

                self._force_close()

                raise

        if len(data) < num_bytes:

            self._force_close()

>           raise err.OperationalError(

                CR.CR_SERVER_LOST, "Lost connection to MySQL server during query"

            )

E           sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

E           (Background on this error at: https://sqlalche.me/e/20/e3q8)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:805: OperationalError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

>       resp = client.get("/api/list-versions", query_string = parameters)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:507: in list_versions

    inc_db_error("list_versions")

observability.py:312: in inc_db_error

    DB_ERRORS.inc(op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_db_errors_total', help='Database operation errors', values={}, label_names=('operation',))

amount = 1.0, label_values = ('list_versions',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) <= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

WARNING  server:server.py:610 Document not found or access denied for id=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



self = <sqlalchemy.engine.base.Connection object at 0x0000021C82059DF0>

dialect = <sqlalchemy.dialects.mysql.pymysql.MySQLDialect_pymysql object at 0x0000021C820E4F80>

context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mysqldb object at 0x0000021C820E5520>

statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb object at 0x0000021C820E5550>

parameters = [{'name': 'Water File', 'ownerid': 1, 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storag...061053810416Z__watermarked.pdf', 'sha256hex': '5fbac867f5efdd7b0ab5c11456b204ddd08ff8801502c93728be3b38bfafe80c', ...}]



    def _exec_single_context(

        self,

        dialect: Dialect,

        context: ExecutionContext,

        statement: Union[str, Compiled],

        parameters: Optional[_AnyMultiExecuteParams],

    ) -> CursorResult[Any]:

        """continue the _execute_context() method for a single DBAPI

        cursor.execute() or cursor.executemany() call.

    

        """

        if dialect.bind_typing is BindTyping.SETINPUTSIZES:

            generic_setinputsizes = context._prepare_set_input_sizes()

    

            if generic_setinputsizes:

                try:

                    dialect.do_set_input_sizes(

                        context.cursor, generic_setinputsizes, context

                    )

                except BaseException as e:

                    self._handle_dbapi_exception(

                        e, str(statement), parameters, None, context

                    )

    

        cursor, str_statement, parameters = (

            context.cursor,

            context.statement,

            context.parameters,

        )

    

        effective_parameters: Optional[_AnyExecuteParams]

    

        if not context.executemany:

            effective_parameters = parameters[0]

        else:

            effective_parameters = parameters

    

        if self._has_events or self.engine._has_events:

            for fn in self.dispatch.before_cursor_execute:

                str_statement, effective_parameters = fn(

                    self,

                    cursor,

                    str_statement,

                    effective_parameters,

                    context,

                    context.executemany,

                )

    

        if self._echo:

            self._log_info(str_statement)

    

            stats = context._get_cache_stats()

    

            if not self.engine.hide_parameters:

                self._log_info(

                    "[%s] %r",

                    stats,

                    sql_util._repr_params(

                        effective_parameters,

                        batches=10,

                        ismulti=context.executemany,

                    ),

                )

            else:

                self._log_info(

                    "[%s] [SQL parameters hidden due to hide_parameters=True]",

                    stats,

                )

    

        evt_handled: bool = False

        try:

            if context.execute_style is ExecuteStyle.EXECUTEMANY:

                effective_parameters = cast(

                    "_CoreMultiExecuteParams", effective_parameters

                )

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_executemany:

                        if fn(

                            cursor,

                            str_statement,

                            effective_parameters,

                            context,

                        ):

                            evt_handled = True

                            break

                if not evt_handled:

                    self.dialect.do_executemany(

                        cursor,

                        str_statement,

                        effective_parameters,

                        context,

                    )

            elif not effective_parameters and context.no_parameters:

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_execute_no_params:

                        if fn(cursor, str_statement, context):

                            evt_handled = True

                            break

                if not evt_handled:

                    self.dialect.do_execute_no_params(

                        cursor, str_statement, context

                    )

            else:

                effective_parameters = cast(

                    "_CoreSingleExecuteParams", effective_parameters

                )

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_execute:

                        if fn(

                            cursor,

                            str_statement,

                            effective_parameters,

                            context,

                        ):

                            evt_handled = True

                            break

                if not evt_handled:

>                   self.dialect.do_execute(

                        cursor, str_statement, effective_parameters, context

                    )



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1967: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:951: in do_execute

    cursor.execute(statement, parameters)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:153: in execute

    result = self._query(query)

             ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:322: in _query

    conn.query(q)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:575: in query

    self._affected_rows = self._read_query_result(unbuffered=unbuffered)

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:826: in _read_query_result

    result.read()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1203: in read

    first_packet = self.connection._read_packet()

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:782: in _read_packet

    packet.raise_for_error()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\protocol.py:219: in raise_for_error

    err.raise_mysql_exception(self._data)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



data = b'\xff\xac\x05#23000Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)'



    def raise_mysql_exception(data):

        errno = struct.unpack("<h", data[1:3])[0]

        # https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html

        # Error packet has optional sqlstate that is 5 bytes and starts with '#'.

        if data[3] == 0x23:  # '#'

            # sqlstate = data[4:9].decode()

            # TODO: Append (sqlstate) in the error message. This will be come in next minor release.

            errval = data[9:].decode("utf-8", "replace")

        else:

            errval = data[3:].decode("utf-8", "replace")

        errorclass = error_map.get(errno)

        if errorclass is None:

            errorclass = InternalError if errno < 1000 else OperationalError

>       raise errorclass(errno, errval)

E       pymysql.err.IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)')



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\err.py:150: IntegrityError



The above exception was the direct cause of the following exception:



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

>               conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )



server.py:365: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1419: in execute

    return meth(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\sql\elements.py:526: in _execute_on_connection

    return connection._execute_clauseelement(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1641: in _execute_clauseelement

    ret = self._execute_context(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1846: in _execute_context

    return self._exec_single_context(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1986: in _exec_single_context

    self._handle_dbapi_exception(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:2355: in _handle_dbapi_exception

    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1967: in _exec_single_context

    self.dialect.do_execute(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:951: in do_execute

    cursor.execute(statement, parameters)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:153: in execute

    result = self._query(query)

             ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:322: in _query

    conn.query(q)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:575: in query

    self._affected_rows = self._read_query_result(unbuffered=unbuffered)

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:826: in _read_query_result

    result.read()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1203: in read

    first_packet = self.connection._read_packet()

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:782: in _read_packet

    packet.raise_for_error()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\protocol.py:219: in raise_for_error

    err.raise_mysql_exception(self._data)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



data = b'\xff\xac\x05#23000Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)'



    def raise_mysql_exception(data):

        errno = struct.unpack("<h", data[1:3])[0]

        # https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html

        # Error packet has optional sqlstate that is 5 bytes and starts with '#'.

        if data[3] == 0x23:  # '#'

            # sqlstate = data[4:9].decode()

            # TODO: Append (sqlstate) in the error message. This will be come in next minor release.

            errval = data[9:].decode("utf-8", "replace")

        else:

            errval = data[3:].decode("utf-8", "replace")

        errorclass = error_map.get(errno)

        if errorclass is None:

            errorclass = InternalError if errno < 1000 else OperationalError

>       raise errorclass(errno, errval)

E       sqlalchemy.exc.IntegrityError: (pymysql.err.IntegrityError) (1452, 'Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)')

E       [SQL: 

E                               INSERT INTO Documents (name, path, ownerid, sha256, size)

E                               VALUES (%(name)s, %(path)s, %(ownerid)s, UNHEX(%(sha256hex)s), %(size)s)

E                           ]

E       [parameters: {'name': 'Water File', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\20251017T061053810416Z__watermarked.pdf', 'ownerid': 1, 'sha256hex': '5fbac867f5efdd7b0ab5c11456b204ddd08ff8801502c93728be3b38bfafe80c', 'size': 39265}]

E       (Background on this error at: https://sqlalche.me/e/20/gkpj)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\err.py:150: IntegrityError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:398: in upload_document

    inc_db_error("insert_document")

observability.py:312: in inc_db_error

    DB_ERRORS.inc(op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_db_errors_total', help='Database operation errors', values={}, label_names=('operation',))

amount = 1.0, label_values = ('insert_document',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) <= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061053810416Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_list_documents_route - ValueError: Label car...

FAILED ..\test\test_api.py::test_list_versions_route - ValueError: Label card...

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 26.78s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if len(label_values) <= len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
.FFF.....FF...                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:236 Database error in create_user: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.11259961128234863, label_values = ('login_select',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) <= len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.0381472110748291, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) <= len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.03791356086730957, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) <= len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

5 failed, 9 passed, 22 warnings in 20.40s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if len(label_values) > len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.93s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if len(label_values) > len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.01s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if len(label_values) >= len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
..FF.....FF...                                                           [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) >= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) >= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:317: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) >= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) >= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - ValueError: Label c...

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

4 failed, 10 passed, 22 warnings in 19.95s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if len(label_values) >= len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
.FFF.....FF...                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:236 Database error in create_user: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.13947391510009766, label_values = ('login_select',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) >= len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.05463719367980957, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) >= len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.04544377326965332, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) >= len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

5 failed, 9 passed, 22 warnings in 19.67s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if len(label_values) is len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

______________________________ test_login_route _______________________________



self = <sqlalchemy.engine.base.Connection object at 0x000001DC00B71010>

engine = Engine(mysql+pymysql://tatou:***@127.0.0.1:3306/tatou?charset=utf8mb4)

connection = None, _has_events = None, _allow_revalidate = True

_allow_autobegin = True



    def __init__(

        self,

        engine: Engine,

        connection: Optional[PoolProxiedConnection] = None,

        _has_events: Optional[bool] = None,

        _allow_revalidate: bool = True,

        _allow_autobegin: bool = True,

    ):

        """Construct a new Connection."""

        self.engine = engine

        self.dialect = dialect = engine.dialect

    

        if connection is None:

            try:

>               self._dbapi_connection = engine.raw_connection()

                                         ^^^^^^^^^^^^^^^^^^^^^^^



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:143: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3301: in raw_connection

    return self.pool.connect()

           ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:447: in connect

    return _ConnectionFairy._checkout(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:1264: in _checkout

    fairy = _ConnectionRecord.checkout(pool)

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:711: in checkout

    rec = pool._do_get()

          ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:177: in _do_get

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:175: in _do_get

    return self._create_connection()

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:388: in _create_connection

    return _ConnectionRecord(self)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:673: in __init__

    self.__connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:899: in __connect

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:895: in __connect

    self.dbapi_connection = connection = pool._invoke_creator(self)

                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py:661: in connect

    return dialect.connect(*cargs, **cparams)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:629: in connect

    return self.loaded_dbapi.connect(*cargs, **cparams)  # type: ignore[no-any-return]  # NOQA: E501

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:365: in __init__

    self.connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:680: in connect

    self._get_server_information()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1099: in _get_server_information

    packet = self._read_packet()

             ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:751: in _read_packet

    packet_header = self._read_bytes(4)

                    ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymysql.connections.Connection object at 0x000001DC00B715E0>

num_bytes = 4



    def _read_bytes(self, num_bytes):

        self._sock.settimeout(self._read_timeout)

        while True:

            try:

                data = self._rfile.read(num_bytes)

                break

            except OSError as e:

                if e.errno == errno.EINTR:

                    continue

                self._force_close()

                raise err.OperationalError(

                    CR.CR_SERVER_LOST,

                    f"Lost connection to MySQL server during query ({e})",

                )

            except BaseException:

                # Don't convert unknown exception to MySQLError.

                self._force_close()

                raise

        if len(data) < num_bytes:

            self._force_close()

>           raise err.OperationalError(

                CR.CR_SERVER_LOST, "Lost connection to MySQL server during query"

            )

E           pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:805: OperationalError



The above exception was the direct cause of the following exception:



    @app.post("/api/login")

    def login():

        payload = request.get_json(silent=True) or {}

        email = (payload.get("email") or "").strip()

        password = payload.get("password") or ""

    

        if not email or not password:

            app.logger.warning("Missing fields in login attempt: %s", payload)

            return jsonify({"error": "email and password are required"}), 400

    

        start_db = time.time()

        try:

>           with get_engine().connect() as conn:

                 ^^^^^^^^^^^^^^^^^^^^^^



server.py:254: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3277: in connect

    return self._connection_cls(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:145: in __init__

    Connection._handle_dbapi_exception_noconnection(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:2440: in _handle_dbapi_exception_noconnection

    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:143: in __init__

    self._dbapi_connection = engine.raw_connection()

                             ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3301: in raw_connection

    return self.pool.connect()

           ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:447: in connect

    return _ConnectionFairy._checkout(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:1264: in _checkout

    fairy = _ConnectionRecord.checkout(pool)

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:711: in checkout

    rec = pool._do_get()

          ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:177: in _do_get

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:175: in _do_get

    return self._create_connection()

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:388: in _create_connection

    return _ConnectionRecord(self)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:673: in __init__

    self.__connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:899: in __connect

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:895: in __connect

    self.dbapi_connection = connection = pool._invoke_creator(self)

                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py:661: in connect

    return dialect.connect(*cargs, **cparams)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:629: in connect

    return self.loaded_dbapi.connect(*cargs, **cparams)  # type: ignore[no-any-return]  # NOQA: E501

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:365: in __init__

    self.connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:680: in connect

    self._get_server_information()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1099: in _get_server_information

    packet = self._read_packet()

             ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:751: in _read_packet

    packet_header = self._read_bytes(4)

                    ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymysql.connections.Connection object at 0x000001DC00B715E0>

num_bytes = 4



    def _read_bytes(self, num_bytes):

        self._sock.settimeout(self._read_timeout)

        while True:

            try:

                data = self._rfile.read(num_bytes)

                break

            except OSError as e:

                if e.errno == errno.EINTR:

                    continue

                self._force_close()

                raise err.OperationalError(

                    CR.CR_SERVER_LOST,

                    f"Lost connection to MySQL server during query ({e})",

                )

            except BaseException:

                # Don't convert unknown exception to MySQLError.

                self._force_close()

                raise

        if len(data) < num_bytes:

            self._force_close()

>           raise err.OperationalError(

                CR.CR_SERVER_LOST, "Lost connection to MySQL server during query"

            )

E           sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

E           (Background on this error at: https://sqlalche.me/e/20/e3q8)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:805: OperationalError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:281: in login

    inc_db_error("login_select")

observability.py:312: in inc_db_error

    DB_ERRORS.inc(op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_db_errors_total', help='Database operation errors', values={}, label_names=('operation',))

amount = 1.0, label_values = ('login_select',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) is len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



self = <sqlalchemy.engine.base.Connection object at 0x000001DC00A6EA50>

engine = Engine(mysql+pymysql://tatou:***@127.0.0.1:3306/tatou?charset=utf8mb4)

connection = None, _has_events = None, _allow_revalidate = True

_allow_autobegin = True



    def __init__(

        self,

        engine: Engine,

        connection: Optional[PoolProxiedConnection] = None,

        _has_events: Optional[bool] = None,

        _allow_revalidate: bool = True,

        _allow_autobegin: bool = True,

    ):

        """Construct a new Connection."""

        self.engine = engine

        self.dialect = dialect = engine.dialect

    

        if connection is None:

            try:

>               self._dbapi_connection = engine.raw_connection()

                                         ^^^^^^^^^^^^^^^^^^^^^^^



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:143: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3301: in raw_connection

    return self.pool.connect()

           ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:447: in connect

    return _ConnectionFairy._checkout(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:1264: in _checkout

    fairy = _ConnectionRecord.checkout(pool)

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:711: in checkout

    rec = pool._do_get()

          ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:177: in _do_get

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:175: in _do_get

    return self._create_connection()

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:388: in _create_connection

    return _ConnectionRecord(self)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:673: in __init__

    self.__connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:899: in __connect

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:895: in __connect

    self.dbapi_connection = connection = pool._invoke_creator(self)

                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py:661: in connect

    return dialect.connect(*cargs, **cparams)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:629: in connect

    return self.loaded_dbapi.connect(*cargs, **cparams)  # type: ignore[no-any-return]  # NOQA: E501

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:365: in __init__

    self.connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:680: in connect

    self._get_server_information()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1099: in _get_server_information

    packet = self._read_packet()

             ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:751: in _read_packet

    packet_header = self._read_bytes(4)

                    ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymysql.connections.Connection object at 0x000001DC00A6ED20>

num_bytes = 4



    def _read_bytes(self, num_bytes):

        self._sock.settimeout(self._read_timeout)

        while True:

            try:

                data = self._rfile.read(num_bytes)

                break

            except OSError as e:

                if e.errno == errno.EINTR:

                    continue

                self._force_close()

                raise err.OperationalError(

                    CR.CR_SERVER_LOST,

                    f"Lost connection to MySQL server during query ({e})",

                )

            except BaseException:

                # Don't convert unknown exception to MySQLError.

                self._force_close()

                raise

        if len(data) < num_bytes:

            self._force_close()

>           raise err.OperationalError(

                CR.CR_SERVER_LOST, "Lost connection to MySQL server during query"

            )

E           pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:805: OperationalError



The above exception was the direct cause of the following exception:



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

>           with get_engine().begin() as conn:



server.py:364: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\contextlib.py:137: in __enter__

    return next(self.gen)

           ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3241: in begin

    with self.connect() as conn:

         ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3277: in connect

    return self._connection_cls(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:145: in __init__

    Connection._handle_dbapi_exception_noconnection(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:2440: in _handle_dbapi_exception_noconnection

    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:143: in __init__

    self._dbapi_connection = engine.raw_connection()

                             ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3301: in raw_connection

    return self.pool.connect()

           ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:447: in connect

    return _ConnectionFairy._checkout(self)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:1264: in _checkout

    fairy = _ConnectionRecord.checkout(pool)

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:711: in checkout

    rec = pool._do_get()

          ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:177: in _do_get

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:175: in _do_get

    return self._create_connection()

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:388: in _create_connection

    return _ConnectionRecord(self)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:673: in __init__

    self.__connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:899: in __connect

    with util.safe_reraise():

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:224: in __exit__

    raise exc_value.with_traceback(exc_tb)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:895: in __connect

    self.dbapi_connection = connection = pool._invoke_creator(self)

                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py:661: in connect

    return dialect.connect(*cargs, **cparams)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:629: in connect

    return self.loaded_dbapi.connect(*cargs, **cparams)  # type: ignore[no-any-return]  # NOQA: E501

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:365: in __init__

    self.connect()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:680: in connect

    self._get_server_information()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1099: in _get_server_information

    packet = self._read_packet()

             ^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:751: in _read_packet

    packet_header = self._read_bytes(4)

                    ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymysql.connections.Connection object at 0x000001DC00A6ED20>

num_bytes = 4



    def _read_bytes(self, num_bytes):

        self._sock.settimeout(self._read_timeout)

        while True:

            try:

                data = self._rfile.read(num_bytes)

                break

            except OSError as e:

                if e.errno == errno.EINTR:

                    continue

                self._force_close()

                raise err.OperationalError(

                    CR.CR_SERVER_LOST,

                    f"Lost connection to MySQL server during query ({e})",

                )

            except BaseException:

                # Don't convert unknown exception to MySQLError.

                self._force_close()

                raise

        if len(data) < num_bytes:

            self._force_close()

>           raise err.OperationalError(

                CR.CR_SERVER_LOST, "Lost connection to MySQL server during query"

            )

E           sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

E           (Background on this error at: https://sqlalche.me/e/20/e3q8)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:805: OperationalError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:398: in upload_document

    inc_db_error("insert_document")

observability.py:312: in inc_db_error

    DB_ERRORS.inc(op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_db_errors_total', help='Database operation errors', values={}, label_names=('operation',))

amount = 1.0, label_values = ('insert_document',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) is len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T175152555283Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

WARNING  server:server.py:486 Document not found or access denied for id=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

WARNING  server:server.py:610 Document not found or access denied for id=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



self = <sqlalchemy.engine.base.Connection object at 0x000001DC00E06210>

dialect = <sqlalchemy.dialects.mysql.pymysql.MySQLDialect_pymysql object at 0x000001DC00E06750>

context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mysqldb object at 0x000001DC00E06AB0>

statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb object at 0x000001DC00E06B10>

parameters = [{'name': 'Water File', 'ownerid': 1, 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storag...175153955789Z__watermarked.pdf', 'sha256hex': '5fbac867f5efdd7b0ab5c11456b204ddd08ff8801502c93728be3b38bfafe80c', ...}]



    def _exec_single_context(

        self,

        dialect: Dialect,

        context: ExecutionContext,

        statement: Union[str, Compiled],

        parameters: Optional[_AnyMultiExecuteParams],

    ) -> CursorResult[Any]:

        """continue the _execute_context() method for a single DBAPI

        cursor.execute() or cursor.executemany() call.

    

        """

        if dialect.bind_typing is BindTyping.SETINPUTSIZES:

            generic_setinputsizes = context._prepare_set_input_sizes()

    

            if generic_setinputsizes:

                try:

                    dialect.do_set_input_sizes(

                        context.cursor, generic_setinputsizes, context

                    )

                except BaseException as e:

                    self._handle_dbapi_exception(

                        e, str(statement), parameters, None, context

                    )

    

        cursor, str_statement, parameters = (

            context.cursor,

            context.statement,

            context.parameters,

        )

    

        effective_parameters: Optional[_AnyExecuteParams]

    

        if not context.executemany:

            effective_parameters = parameters[0]

        else:

            effective_parameters = parameters

    

        if self._has_events or self.engine._has_events:

            for fn in self.dispatch.before_cursor_execute:

                str_statement, effective_parameters = fn(

                    self,

                    cursor,

                    str_statement,

                    effective_parameters,

                    context,

                    context.executemany,

                )

    

        if self._echo:

            self._log_info(str_statement)

    

            stats = context._get_cache_stats()

    

            if not self.engine.hide_parameters:

                self._log_info(

                    "[%s] %r",

                    stats,

                    sql_util._repr_params(

                        effective_parameters,

                        batches=10,

                        ismulti=context.executemany,

                    ),

                )

            else:

                self._log_info(

                    "[%s] [SQL parameters hidden due to hide_parameters=True]",

                    stats,

                )

    

        evt_handled: bool = False

        try:

            if context.execute_style is ExecuteStyle.EXECUTEMANY:

                effective_parameters = cast(

                    "_CoreMultiExecuteParams", effective_parameters

                )

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_executemany:

                        if fn(

                            cursor,

                            str_statement,

                            effective_parameters,

                            context,

                        ):

                            evt_handled = True

                            break

                if not evt_handled:

                    self.dialect.do_executemany(

                        cursor,

                        str_statement,

                        effective_parameters,

                        context,

                    )

            elif not effective_parameters and context.no_parameters:

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_execute_no_params:

                        if fn(cursor, str_statement, context):

                            evt_handled = True

                            break

                if not evt_handled:

                    self.dialect.do_execute_no_params(

                        cursor, str_statement, context

                    )

            else:

                effective_parameters = cast(

                    "_CoreSingleExecuteParams", effective_parameters

                )

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_execute:

                        if fn(

                            cursor,

                            str_statement,

                            effective_parameters,

                            context,

                        ):

                            evt_handled = True

                            break

                if not evt_handled:

>                   self.dialect.do_execute(

                        cursor, str_statement, effective_parameters, context

                    )



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1967: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:951: in do_execute

    cursor.execute(statement, parameters)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:153: in execute

    result = self._query(query)

             ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:322: in _query

    conn.query(q)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:575: in query

    self._affected_rows = self._read_query_result(unbuffered=unbuffered)

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:826: in _read_query_result

    result.read()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1203: in read

    first_packet = self.connection._read_packet()

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:782: in _read_packet

    packet.raise_for_error()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\protocol.py:219: in raise_for_error

    err.raise_mysql_exception(self._data)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



data = b'\xff\xac\x05#23000Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)'



    def raise_mysql_exception(data):

        errno = struct.unpack("<h", data[1:3])[0]

        # https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html

        # Error packet has optional sqlstate that is 5 bytes and starts with '#'.

        if data[3] == 0x23:  # '#'

            # sqlstate = data[4:9].decode()

            # TODO: Append (sqlstate) in the error message. This will be come in next minor release.

            errval = data[9:].decode("utf-8", "replace")

        else:

            errval = data[3:].decode("utf-8", "replace")

        errorclass = error_map.get(errno)

        if errorclass is None:

            errorclass = InternalError if errno < 1000 else OperationalError

>       raise errorclass(errno, errval)

E       pymysql.err.IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)')



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\err.py:150: IntegrityError



The above exception was the direct cause of the following exception:



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

>               conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )



server.py:365: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1419: in execute

    return meth(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\sql\elements.py:526: in _execute_on_connection

    return connection._execute_clauseelement(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1641: in _execute_clauseelement

    ret = self._execute_context(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1846: in _execute_context

    return self._exec_single_context(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1986: in _exec_single_context

    self._handle_dbapi_exception(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:2355: in _handle_dbapi_exception

    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1967: in _exec_single_context

    self.dialect.do_execute(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:951: in do_execute

    cursor.execute(statement, parameters)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:153: in execute

    result = self._query(query)

             ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:322: in _query

    conn.query(q)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:575: in query

    self._affected_rows = self._read_query_result(unbuffered=unbuffered)

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:826: in _read_query_result

    result.read()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1203: in read

    first_packet = self.connection._read_packet()

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:782: in _read_packet

    packet.raise_for_error()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\protocol.py:219: in raise_for_error

    err.raise_mysql_exception(self._data)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



data = b'\xff\xac\x05#23000Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)'



    def raise_mysql_exception(data):

        errno = struct.unpack("<h", data[1:3])[0]

        # https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html

        # Error packet has optional sqlstate that is 5 bytes and starts with '#'.

        if data[3] == 0x23:  # '#'

            # sqlstate = data[4:9].decode()

            # TODO: Append (sqlstate) in the error message. This will be come in next minor release.

            errval = data[9:].decode("utf-8", "replace")

        else:

            errval = data[3:].decode("utf-8", "replace")

        errorclass = error_map.get(errno)

        if errorclass is None:

            errorclass = InternalError if errno < 1000 else OperationalError

>       raise errorclass(errno, errval)

E       sqlalchemy.exc.IntegrityError: (pymysql.err.IntegrityError) (1452, 'Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)')

E       [SQL: 

E                               INSERT INTO Documents (name, path, ownerid, sha256, size)

E                               VALUES (%(name)s, %(path)s, %(ownerid)s, UNHEX(%(sha256hex)s), %(size)s)

E                           ]

E       [parameters: {'name': 'Water File', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\20251016T175153955789Z__watermarked.pdf', 'ownerid': 1, 'sha256hex': '5fbac867f5efdd7b0ab5c11456b204ddd08ff8801502c93728be3b38bfafe80c', 'size': 39265}]

E       (Background on this error at: https://sqlalche.me/e/20/gkpj)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\err.py:150: IntegrityError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:398: in upload_document

    inc_db_error("insert_document")

observability.py:312: in inc_db_error

    DB_ERRORS.inc(op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_db_errors_total', help='Database operation errors', values={}, label_names=('operation',))

amount = 1.0, label_values = ('insert_document',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) is len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T175153955789Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.76s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if len(label_values) is len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T192229009490Z__input.pdf user=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T192229912159Z__watermarked.pdf user=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.71s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if len(label_values) is not len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.99s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if len(label_values) is not len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceComparisonOperator_Lt_Eq, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None or size == 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceComparisonOperator_Lt_NotEq, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None or size != 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.53s

operator: core/ReplaceComparisonOperator_Lt_LtE, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None or size <= 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T023723717472Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T023724611190Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.21s

operator: core/ReplaceComparisonOperator_Lt_Gt, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None or size > 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ReplaceComparisonOperator_Lt_GtE, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None or size >= 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054504182837Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054505131153Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.45s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if value == b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ebbdbac663ed3905c: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.64s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if value != b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T012904950759Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T012905942421Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.47s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if value < b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T141808610287Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T141809407367Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.95s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if value > b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if value >= b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/ReplaceComparisonOperator_LtE_Is, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if value is b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T185749239791Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T185750109286Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.83s

operator: core/ReplaceComparisonOperator_LtE_IsNot, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if value is not b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.61s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is not None or size < 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.58s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if not len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

______________________________ test_login_route _______________________________



    @app.post("/api/login")

    def login():

        payload = request.get_json(silent=True) or {}

        email = (payload.get("email") or "").strip()

        password = payload.get("password") or ""

    

        if not email or not password:

            app.logger.warning("Missing fields in login attempt: %s", payload)

            return jsonify({"error": "email and password are required"}), 400

    

        start_db = time.time()

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        "SELECT id, email, login, hpassword FROM Users "

                        "WHERE email = :email LIMIT 1"

                    ),

                    {"email": email},

                ).first()

    

                # Constant-time comparison to prevent timing attacks

                if row:

                    is_valid = check_password_hash(row.hpassword, password)

                else:

                    # Dummy check to maintain constant time

                    is_valid = False

                    row = None

    

                if not is_valid:

                    app.logger.warning(

                        "Failed login attempt for email: %s",

                        email if email else "<empty>",

                    )

>                   inc_login_failure("invalid_credentials")



server.py:276: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

observability.py:271: in inc_login_failure

    LOGIN_FAILURES.inc(reason)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_failures_total', help='Number of failed login attempts', values={}, label_names=('reason',))

amount = 1.0, label_values = ('invalid_credentials',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if not len(label_values) != len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:281: in login

    inc_db_error("login_select")

observability.py:312: in inc_db_error

    DB_ERRORS.inc(op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_db_errors_total', help='Database operation errors', values={}, label_names=('operation',))

amount = 1.0, label_values = ('login_select',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if not len(label_values) != len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

ERROR    server:server.py:280 Database error in login: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



self = <sqlalchemy.engine.base.Connection object at 0x000001F6AB04ED80>

dialect = <sqlalchemy.dialects.mysql.pymysql.MySQLDialect_pymysql object at 0x000001F6AB04F290>

context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mysqldb object at 0x000001F6AB04F740>

statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb object at 0x000001F6AB04EED0>

parameters = [{'name': 'My File', 'ownerid': 1, 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\...51016T163905268469Z__input.pdf', 'sha256hex': '5fbac867f5efdd7b0ab5c11456b204ddd08ff8801502c93728be3b38bfafe80c', ...}]



    def _exec_single_context(

        self,

        dialect: Dialect,

        context: ExecutionContext,

        statement: Union[str, Compiled],

        parameters: Optional[_AnyMultiExecuteParams],

    ) -> CursorResult[Any]:

        """continue the _execute_context() method for a single DBAPI

        cursor.execute() or cursor.executemany() call.

    

        """

        if dialect.bind_typing is BindTyping.SETINPUTSIZES:

            generic_setinputsizes = context._prepare_set_input_sizes()

    

            if generic_setinputsizes:

                try:

                    dialect.do_set_input_sizes(

                        context.cursor, generic_setinputsizes, context

                    )

                except BaseException as e:

                    self._handle_dbapi_exception(

                        e, str(statement), parameters, None, context

                    )

    

        cursor, str_statement, parameters = (

            context.cursor,

            context.statement,

            context.parameters,

        )

    

        effective_parameters: Optional[_AnyExecuteParams]

    

        if not context.executemany:

            effective_parameters = parameters[0]

        else:

            effective_parameters = parameters

    

        if self._has_events or self.engine._has_events:

            for fn in self.dispatch.before_cursor_execute:

                str_statement, effective_parameters = fn(

                    self,

                    cursor,

                    str_statement,

                    effective_parameters,

                    context,

                    context.executemany,

                )

    

        if self._echo:

            self._log_info(str_statement)

    

            stats = context._get_cache_stats()

    

            if not self.engine.hide_parameters:

                self._log_info(

                    "[%s] %r",

                    stats,

                    sql_util._repr_params(

                        effective_parameters,

                        batches=10,

                        ismulti=context.executemany,

                    ),

                )

            else:

                self._log_info(

                    "[%s] [SQL parameters hidden due to hide_parameters=True]",

                    stats,

                )

    

        evt_handled: bool = False

        try:

            if context.execute_style is ExecuteStyle.EXECUTEMANY:

                effective_parameters = cast(

                    "_CoreMultiExecuteParams", effective_parameters

                )

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_executemany:

                        if fn(

                            cursor,

                            str_statement,

                            effective_parameters,

                            context,

                        ):

                            evt_handled = True

                            break

                if not evt_handled:

                    self.dialect.do_executemany(

                        cursor,

                        str_statement,

                        effective_parameters,

                        context,

                    )

            elif not effective_parameters and context.no_parameters:

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_execute_no_params:

                        if fn(cursor, str_statement, context):

                            evt_handled = True

                            break

                if not evt_handled:

                    self.dialect.do_execute_no_params(

                        cursor, str_statement, context

                    )

            else:

                effective_parameters = cast(

                    "_CoreSingleExecuteParams", effective_parameters

                )

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_execute:

                        if fn(

                            cursor,

                            str_statement,

                            effective_parameters,

                            context,

                        ):

                            evt_handled = True

                            break

                if not evt_handled:

>                   self.dialect.do_execute(

                        cursor, str_statement, effective_parameters, context

                    )



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1967: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:951: in do_execute

    cursor.execute(statement, parameters)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:153: in execute

    result = self._query(query)

             ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:322: in _query

    conn.query(q)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:575: in query

    self._affected_rows = self._read_query_result(unbuffered=unbuffered)

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:826: in _read_query_result

    result.read()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1203: in read

    first_packet = self.connection._read_packet()

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:782: in _read_packet

    packet.raise_for_error()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\protocol.py:219: in raise_for_error

    err.raise_mysql_exception(self._data)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



data = b'\xff\xac\x05#23000Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)'



    def raise_mysql_exception(data):

        errno = struct.unpack("<h", data[1:3])[0]

        # https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html

        # Error packet has optional sqlstate that is 5 bytes and starts with '#'.

        if data[3] == 0x23:  # '#'

            # sqlstate = data[4:9].decode()

            # TODO: Append (sqlstate) in the error message. This will be come in next minor release.

            errval = data[9:].decode("utf-8", "replace")

        else:

            errval = data[3:].decode("utf-8", "replace")

        errorclass = error_map.get(errno)

        if errorclass is None:

            errorclass = InternalError if errno < 1000 else OperationalError

>       raise errorclass(errno, errval)

E       pymysql.err.IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)')



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\err.py:150: IntegrityError



The above exception was the direct cause of the following exception:



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

>               conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )



server.py:365: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1419: in execute

    return meth(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\sql\elements.py:526: in _execute_on_connection

    return connection._execute_clauseelement(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1641: in _execute_clauseelement

    ret = self._execute_context(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1846: in _execute_context

    return self._exec_single_context(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1986: in _exec_single_context

    self._handle_dbapi_exception(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:2355: in _handle_dbapi_exception

    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1967: in _exec_single_context

    self.dialect.do_execute(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:951: in do_execute

    cursor.execute(statement, parameters)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:153: in execute

    result = self._query(query)

             ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:322: in _query

    conn.query(q)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:575: in query

    self._affected_rows = self._read_query_result(unbuffered=unbuffered)

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:826: in _read_query_result

    result.read()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1203: in read

    first_packet = self.connection._read_packet()

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:782: in _read_packet

    packet.raise_for_error()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\protocol.py:219: in raise_for_error

    err.raise_mysql_exception(self._data)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



data = b'\xff\xac\x05#23000Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)'



    def raise_mysql_exception(data):

        errno = struct.unpack("<h", data[1:3])[0]

        # https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html

        # Error packet has optional sqlstate that is 5 bytes and starts with '#'.

        if data[3] == 0x23:  # '#'

            # sqlstate = data[4:9].decode()

            # TODO: Append (sqlstate) in the error message. This will be come in next minor release.

            errval = data[9:].decode("utf-8", "replace")

        else:

            errval = data[3:].decode("utf-8", "replace")

        errorclass = error_map.get(errno)

        if errorclass is None:

            errorclass = InternalError if errno < 1000 else OperationalError

>       raise errorclass(errno, errval)

E       sqlalchemy.exc.IntegrityError: (pymysql.err.IntegrityError) (1452, 'Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)')

E       [SQL: 

E                               INSERT INTO Documents (name, path, ownerid, sha256, size)

E                               VALUES (%(name)s, %(path)s, %(ownerid)s, UNHEX(%(sha256hex)s), %(size)s)

E                           ]

E       [parameters: {'name': 'My File', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\20251016T163905268469Z__input.pdf', 'ownerid': 1, 'sha256hex': '5fbac867f5efdd7b0ab5c11456b204ddd08ff8801502c93728be3b38bfafe80c', 'size': 39265}]

E       (Background on this error at: https://sqlalche.me/e/20/gkpj)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\err.py:150: IntegrityError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:398: in upload_document

    inc_db_error("insert_document")

observability.py:312: in inc_db_error

    DB_ERRORS.inc(op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_db_errors_total', help='Database operation errors', values={}, label_names=('operation',))

amount = 1.0, label_values = ('insert_document',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if not len(label_values) != len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T163905268469Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

WARNING  server:server.py:486 Document not found or access denied for id=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

WARNING  server:server.py:610 Document not found or access denied for id=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



self = <sqlalchemy.engine.base.Connection object at 0x000001F6AB107860>

dialect = <sqlalchemy.dialects.mysql.pymysql.MySQLDialect_pymysql object at 0x000001F6AB107890>

context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mysqldb object at 0x000001F6AB107FE0>

statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb object at 0x000001F6AB107E90>

parameters = [{'name': 'Water File', 'ownerid': 1, 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storag...163906690162Z__watermarked.pdf', 'sha256hex': '5fbac867f5efdd7b0ab5c11456b204ddd08ff8801502c93728be3b38bfafe80c', ...}]



    def _exec_single_context(

        self,

        dialect: Dialect,

        context: ExecutionContext,

        statement: Union[str, Compiled],

        parameters: Optional[_AnyMultiExecuteParams],

    ) -> CursorResult[Any]:

        """continue the _execute_context() method for a single DBAPI

        cursor.execute() or cursor.executemany() call.

    

        """

        if dialect.bind_typing is BindTyping.SETINPUTSIZES:

            generic_setinputsizes = context._prepare_set_input_sizes()

    

            if generic_setinputsizes:

                try:

                    dialect.do_set_input_sizes(

                        context.cursor, generic_setinputsizes, context

                    )

                except BaseException as e:

                    self._handle_dbapi_exception(

                        e, str(statement), parameters, None, context

                    )

    

        cursor, str_statement, parameters = (

            context.cursor,

            context.statement,

            context.parameters,

        )

    

        effective_parameters: Optional[_AnyExecuteParams]

    

        if not context.executemany:

            effective_parameters = parameters[0]

        else:

            effective_parameters = parameters

    

        if self._has_events or self.engine._has_events:

            for fn in self.dispatch.before_cursor_execute:

                str_statement, effective_parameters = fn(

                    self,

                    cursor,

                    str_statement,

                    effective_parameters,

                    context,

                    context.executemany,

                )

    

        if self._echo:

            self._log_info(str_statement)

    

            stats = context._get_cache_stats()

    

            if not self.engine.hide_parameters:

                self._log_info(

                    "[%s] %r",

                    stats,

                    sql_util._repr_params(

                        effective_parameters,

                        batches=10,

                        ismulti=context.executemany,

                    ),

                )

            else:

                self._log_info(

                    "[%s] [SQL parameters hidden due to hide_parameters=True]",

                    stats,

                )

    

        evt_handled: bool = False

        try:

            if context.execute_style is ExecuteStyle.EXECUTEMANY:

                effective_parameters = cast(

                    "_CoreMultiExecuteParams", effective_parameters

                )

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_executemany:

                        if fn(

                            cursor,

                            str_statement,

                            effective_parameters,

                            context,

                        ):

                            evt_handled = True

                            break

                if not evt_handled:

                    self.dialect.do_executemany(

                        cursor,

                        str_statement,

                        effective_parameters,

                        context,

                    )

            elif not effective_parameters and context.no_parameters:

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_execute_no_params:

                        if fn(cursor, str_statement, context):

                            evt_handled = True

                            break

                if not evt_handled:

                    self.dialect.do_execute_no_params(

                        cursor, str_statement, context

                    )

            else:

                effective_parameters = cast(

                    "_CoreSingleExecuteParams", effective_parameters

                )

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_execute:

                        if fn(

                            cursor,

                            str_statement,

                            effective_parameters,

                            context,

                        ):

                            evt_handled = True

                            break

                if not evt_handled:

>                   self.dialect.do_execute(

                        cursor, str_statement, effective_parameters, context

                    )



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1967: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:951: in do_execute

    cursor.execute(statement, parameters)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:153: in execute

    result = self._query(query)

             ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:322: in _query

    conn.query(q)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:575: in query

    self._affected_rows = self._read_query_result(unbuffered=unbuffered)

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:826: in _read_query_result

    result.read()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1203: in read

    first_packet = self.connection._read_packet()

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:782: in _read_packet

    packet.raise_for_error()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\protocol.py:219: in raise_for_error

    err.raise_mysql_exception(self._data)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



data = b'\xff\xac\x05#23000Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)'



    def raise_mysql_exception(data):

        errno = struct.unpack("<h", data[1:3])[0]

        # https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html

        # Error packet has optional sqlstate that is 5 bytes and starts with '#'.

        if data[3] == 0x23:  # '#'

            # sqlstate = data[4:9].decode()

            # TODO: Append (sqlstate) in the error message. This will be come in next minor release.

            errval = data[9:].decode("utf-8", "replace")

        else:

            errval = data[3:].decode("utf-8", "replace")

        errorclass = error_map.get(errno)

        if errorclass is None:

            errorclass = InternalError if errno < 1000 else OperationalError

>       raise errorclass(errno, errval)

E       pymysql.err.IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)')



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\err.py:150: IntegrityError



The above exception was the direct cause of the following exception:



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

>               conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )



server.py:365: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1419: in execute

    return meth(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\sql\elements.py:526: in _execute_on_connection

    return connection._execute_clauseelement(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1641: in _execute_clauseelement

    ret = self._execute_context(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1846: in _execute_context

    return self._exec_single_context(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1986: in _exec_single_context

    self._handle_dbapi_exception(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:2355: in _handle_dbapi_exception

    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1967: in _exec_single_context

    self.dialect.do_execute(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:951: in do_execute

    cursor.execute(statement, parameters)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:153: in execute

    result = self._query(query)

             ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:322: in _query

    conn.query(q)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:575: in query

    self._affected_rows = self._read_query_result(unbuffered=unbuffered)

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:826: in _read_query_result

    result.read()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1203: in read

    first_packet = self.connection._read_packet()

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:782: in _read_packet

    packet.raise_for_error()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\protocol.py:219: in raise_for_error

    err.raise_mysql_exception(self._data)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



data = b'\xff\xac\x05#23000Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)'



    def raise_mysql_exception(data):

        errno = struct.unpack("<h", data[1:3])[0]

        # https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html

        # Error packet has optional sqlstate that is 5 bytes and starts with '#'.

        if data[3] == 0x23:  # '#'

            # sqlstate = data[4:9].decode()

            # TODO: Append (sqlstate) in the error message. This will be come in next minor release.

            errval = data[9:].decode("utf-8", "replace")

        else:

            errval = data[3:].decode("utf-8", "replace")

        errorclass = error_map.get(errno)

        if errorclass is None:

            errorclass = InternalError if errno < 1000 else OperationalError

>       raise errorclass(errno, errval)

E       sqlalchemy.exc.IntegrityError: (pymysql.err.IntegrityError) (1452, 'Cannot add or update a child row: a foreign key constraint fails (`tatou`.`Documents`, CONSTRAINT `fk_documents_owner` FOREIGN KEY (`ownerid`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)')

E       [SQL: 

E                               INSERT INTO Documents (name, path, ownerid, sha256, size)

E                               VALUES (%(name)s, %(path)s, %(ownerid)s, UNHEX(%(sha256hex)s), %(size)s)

E                           ]

E       [parameters: {'name': 'Water File', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\20251016T163906690162Z__watermarked.pdf', 'ownerid': 1, 'sha256hex': '5fbac867f5efdd7b0ab5c11456b204ddd08ff8801502c93728be3b38bfafe80c', 'size': 39265}]

E       (Background on this error at: https://sqlalche.me/e/20/gkpj)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\err.py:150: IntegrityError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:398: in upload_document

    inc_db_error("insert_document")

observability.py:312: in inc_db_error

    DB_ERRORS.inc(op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_db_errors_total', help='Database operation errors', values={}, label_names=('operation',))

amount = 1.0, label_values = ('insert_document',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if not len(label_values) != len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T163906690162Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.25s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if not len(label_values) != len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
.FFF.....FF...                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:236 Database error in create_user: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:111: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.12988042831420898, label_values = ('login_select',)



    def observe(self, value: float, *label_values: str) -> None:

        if not len(label_values) != len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:147: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.07486772537231445, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if not len(label_values) != len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:387: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.03587532043457031, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if not len(label_values) != len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

5 failed, 9 passed, 22 warnings in 20.02s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if not value <= b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -250,7 +250,7 @@
         REQUEST_LATENCY.observe(duration, method, route)
         # decrement in-flight if previously incremented
         key = (route,)
-        if INFLIGHT.values.get(key):
+        if not INFLIGHT.values.get(key):
             INFLIGHT.values[key] -= 1
 
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.74s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if not size is None or size < 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010434406764Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010435383684Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.35s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -25,7 +25,7 @@
 from time import time
 
 
-@dataclass(slots=True)
+@dataclass(slots=False)
 class CounterMetric:
     name: str
     help: str
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.63s

operator: core/ReplaceTrueWithFalse, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -44,7 +44,7 @@
         for labels, value in sorted(self.values.items()):
             label_frag = ",".join(
                 f"{k}={_quote(v)}"
-                for k, v in zip(self.label_names, labels, strict=True)
+                for k, v in zip(self.label_names, labels, strict=False)
             )
             lines.append(f"{self.name}{{{label_frag}}} {value}")
         return "\n".join(lines)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T190116605795Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T190117491419Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.92s

operator: core/ReplaceTrueWithFalse, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -50,7 +50,7 @@
         return "\n".join(lines)
 
 
-@dataclass(slots=True)
+@dataclass(slots=False)
 class HistogramMetric:
     name: str
     help: str
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/ReplaceTrueWithFalse, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -86,7 +86,7 @@
         for labels in label_sets:
             label_frag = ",".join(
                 f"{k}={_quote(v)}"
-                for k, v in zip(self.label_names, labels, strict=True)
+                for k, v in zip(self.label_names, labels, strict=False)
             )
             # Emit stored cumulative counts for each finite bucket
             for b in self.buckets:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T052446236908Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T052447102690Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.80s

operator: core/ReplaceFalseWithTrue, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -330,5 +330,5 @@
 
     def __exit__(self):
         self.elapsed = time() - self._start
-        return False
-
+        return True
+
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.36s

operator: core/ReplaceOrWithAnd, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None and size < 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T152945329940Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T152946169234Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.14s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -33,7 +33,7 @@
     values: dict[tuple[str, ...], float]
     label_names: tuple[str, ...]
 
-    def inc(self, *label_values: str, amount: float = 1.0) -> None:
+    def inc(self, *label_values: str, amount: float = 2.0) -> None:
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -33,7 +33,7 @@
     values: dict[tuple[str, ...], float]
     label_names: tuple[str, ...]
 
-    def inc(self, *label_values: str, amount: float = 1.0) -> None:
+    def inc(self, *label_values: str, amount: float = 0.0) -> None:
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.52s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 1.0) + amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, -1.0) + amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T183031515422Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T183032406727Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.09s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 1) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.43s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), -1) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T224039568893Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T224040484305Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.61s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 2
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.93s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 0
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031737064477Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031737902379Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.12s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 1) + 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, -1) + 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/NumberReplacer, occurrence: 10
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) + 2
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T044929317924Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T044930201171Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.38s

operator: core/NumberReplacer, occurrence: 11
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) + 0
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/NumberReplacer, occurrence: 12
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 1.0) + value
 
     def render(self) -> str:
         # Prometheus histogram:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.69s

operator: core/NumberReplacer, occurrence: 13
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, -1.0) + value
 
     def render(self) -> str:
         # Prometheus histogram:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614efa6ec95cb6bcc5a4: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.69s

operator: core/NumberReplacer, occurrence: 14
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -90,7 +90,7 @@
             )
             # Emit stored cumulative counts for each finite bucket
             for b in self.buckets:
-                c = self.counts.get((labels, b), 0)
+                c = self.counts.get((labels, b), 1)
                 lines.append(
                     f"{self.name}_bucket{{{label_frag},le={_quote(repr(b))}}} {c}"
                 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.21s

operator: core/NumberReplacer, occurrence: 15
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -90,7 +90,7 @@
             )
             # Emit stored cumulative counts for each finite bucket
             for b in self.buckets:
-                c = self.counts.get((labels, b), 0)
+                c = self.counts.get((labels, b), -1)
                 lines.append(
                     f"{self.name}_bucket{{{label_frag},le={_quote(repr(b))}}} {c}"
                 )
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T044020319607Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T044021252025Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.57s

operator: core/NumberReplacer, occurrence: 16
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -95,7 +95,7 @@
                     f"{self.name}_bucket{{{label_frag},le={_quote(repr(b))}}} {c}"
                 )
             # +Inf bucket / total
-            total = self.counts.get((labels, float("inf")), 0)
+            total = self.counts.get((labels, float("inf")), 1)
             lines.append(
                 f"{self.name}_bucket{{{label_frag},le={_quote('+Inf')}}} {total}"
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/NumberReplacer, occurrence: 17
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -95,7 +95,7 @@
                     f"{self.name}_bucket{{{label_frag},le={_quote(repr(b))}}} {c}"
                 )
             # +Inf bucket / total
-            total = self.counts.get((labels, float("inf")), 0)
+            total = self.counts.get((labels, float("inf")), -1)
             lines.append(
                 f"{self.name}_bucket{{{label_frag},le={_quote('+Inf')}}} {total}"
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.89s

operator: core/NumberReplacer, occurrence: 18
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -100,7 +100,7 @@
                 f"{self.name}_bucket{{{label_frag},le={_quote('+Inf')}}} {total}"
             )
             lines.append(
-                f"{self.name}_sum{{{label_frag}}} {self.sums.get(labels, 0.0)}"
+                f"{self.name}_sum{{{label_frag}}} {self.sums.get(labels, 1.0)}"
             )
             lines.append(f"{self.name}_count{{{label_frag}}} {total}")
         return "\n".join(lines)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002652814057Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002653747727Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.21s

operator: core/NumberReplacer, occurrence: 19
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -100,7 +100,7 @@
                 f"{self.name}_bucket{{{label_frag},le={_quote('+Inf')}}} {total}"
             )
             lines.append(
-                f"{self.name}_sum{{{label_frag}}} {self.sums.get(labels, 0.0)}"
+                f"{self.name}_sum{{{label_frag}}} {self.sums.get(labels, -1.0)}"
             )
             lines.append(f"{self.name}_count{{{label_frag}}} {total}")
         return "\n".join(lines)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T143323956805Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T143324868218Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.23s

operator: core/NumberReplacer, occurrence: 20
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=( 1.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/NumberReplacer, occurrence: 21
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=( -0.995, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.03s

operator: core/NumberReplacer, occurrence: 22
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 1.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/NumberReplacer, occurrence: 23
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, -0.99, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.27s

operator: core/NumberReplacer, occurrence: 24
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 1.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.42s

operator: core/NumberReplacer, occurrence: 25
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, -0.975, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
...F.....FFF.F                                                           [100%]
operator: core/NumberReplacer, occurrence: 26
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 1.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/NumberReplacer, occurrence: 27
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, -0.95, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.12s

operator: core/NumberReplacer, occurrence: 28
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 1.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/NumberReplacer, occurrence: 29
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, -0.9, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.31s

operator: core/NumberReplacer, occurrence: 30
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 1.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/NumberReplacer, occurrence: 31
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, -0.75, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.95s

operator: core/NumberReplacer, occurrence: 32
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 1.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e5a83419b09741a36: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.71s

operator: core/NumberReplacer, occurrence: 33
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, -0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/NumberReplacer, occurrence: 34
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 2.0, 2.5, 5.0),
     counts={},
     sums={},
 )
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.40s

operator: core/NumberReplacer, occurrence: 35
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 0.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/NumberReplacer, occurrence: 36
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 3.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.04s

operator: core/NumberReplacer, occurrence: 37
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 1.5, 5.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/NumberReplacer, occurrence: 38
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 6.0),
     counts={},
     sums={},
 )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T233854033410Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T233854921495Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.32s

operator: core/NumberReplacer, occurrence: 39
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 4.0),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/NumberReplacer, occurrence: 40
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=( 1.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T160130650020Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T160131500317Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.35s

operator: core/NumberReplacer, occurrence: 41
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=( -0.999, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011931282143Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011932185191Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.27s

operator: core/NumberReplacer, occurrence: 42
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 1.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/NumberReplacer, occurrence: 43
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, -0.995, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
...F.....FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

4 failed, 10 passed, 22 warnings in 19.70s

operator: core/NumberReplacer, occurrence: 44
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 1.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193449052231Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193449992413Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.80s

operator: core/NumberReplacer, occurrence: 45
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, -0.99, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e5d1c4167ccd6ecd9: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.44s

operator: core/NumberReplacer, occurrence: 46
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 1.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e8db0232e3b4e8ccf: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.00s

operator: core/NumberReplacer, occurrence: 47
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, -0.975, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.60s

operator: core/NumberReplacer, occurrence: 48
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 1.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.51s

operator: core/NumberReplacer, occurrence: 49
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, -0.95, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011152725868Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011153625895Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.50s

operator: core/NumberReplacer, occurrence: 50
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 1.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/NumberReplacer, occurrence: 51
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, -0.9, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/NumberReplacer, occurrence: 52
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 1.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T144952876825Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T144953751118Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.28s

operator: core/NumberReplacer, occurrence: 53
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, -0.75, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/NumberReplacer, occurrence: 54
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 1.5, 1, 2.5),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.79s

operator: core/NumberReplacer, occurrence: 55
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, -0.5, 1, 2.5),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.07s

operator: core/NumberReplacer, occurrence: 56
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 2, 2.5),
     counts={},
     sums={},
 )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T194707213537Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T194708115582Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.87s

operator: core/NumberReplacer, occurrence: 57
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 0, 2.5),
     counts={},
     sums={},
 )
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223625268575Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223626119639Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.41s

operator: core/NumberReplacer, occurrence: 58
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 3.5),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/NumberReplacer, occurrence: 59
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 1.5),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.36s

operator: core/NumberReplacer, occurrence: 60
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=( 1.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/NumberReplacer, occurrence: 61
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=( -0.995, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T194540171272Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T194541187337Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.89s

operator: core/NumberReplacer, occurrence: 62
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 1.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/NumberReplacer, occurrence: 63
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, -0.99, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T202223962468Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T202224813473Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.57s

operator: core/NumberReplacer, occurrence: 64
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 1.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/NumberReplacer, occurrence: 65
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, -0.975, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/NumberReplacer, occurrence: 66
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 1.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T022638433654Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T022639339457Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.36s

operator: core/NumberReplacer, occurrence: 67
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, -0.95, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/NumberReplacer, occurrence: 68
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 1.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.47s

operator: core/NumberReplacer, occurrence: 69
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, -0.9, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e50ce8a7b9fb1d713: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.04s

operator: core/NumberReplacer, occurrence: 70
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 1.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T184800629029Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T184801621438Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.74s

operator: core/NumberReplacer, occurrence: 71
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, -0.75, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.61s

operator: core/NumberReplacer, occurrence: 72
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 1.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/NumberReplacer, occurrence: 73
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, -0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.79s

operator: core/NumberReplacer, occurrence: 74
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 2, 2.5, 5, 10),
     counts={},
     sums={},
 )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T213306837019Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T213307722939Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.37s

operator: core/NumberReplacer, occurrence: 75
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 0, 2.5, 5, 10),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/NumberReplacer, occurrence: 76
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 3.5, 5, 10),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/NumberReplacer, occurrence: 77
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 1.5, 5, 10),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.92s

operator: core/NumberReplacer, occurrence: 78
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 6, 10),
     counts={},
     sums={},
 )
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eaf00d2435a860c05: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 79
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 4, 10),
     counts={},
     sums={},
 )
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T165301383420Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T165302282976Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.33s

operator: core/NumberReplacer, occurrence: 80
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 11),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.50s

operator: core/NumberReplacer, occurrence: 81
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 9),
     counts={},
     sums={},
 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.44s

operator: core/NumberReplacer, occurrence: 82
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -207,8 +207,7 @@
     name="tatou_http_request_body_bytes",
     help="Request body sizes in bytes (Content-Length if present)",
     label_names=("method", "route"),
-    buckets=(
-        100,
+    buckets=( 101,
         500,
         1_000,
         5_000,
...F.....FFF.F                                                           [100%]
operator: core/NumberReplacer, occurrence: 83
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -207,8 +207,7 @@
     name="tatou_http_request_body_bytes",
     help="Request body sizes in bytes (Content-Length if present)",
     label_names=("method", "route"),
-    buckets=(
-        100,
+    buckets=( 99,
         500,
         1_000,
         5_000,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/NumberReplacer, occurrence: 84
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -208,8 +208,7 @@
     help="Request body sizes in bytes (Content-Length if present)",
     label_names=("method", "route"),
     buckets=(
-        100,
-        500,
+        100, 501,
         1_000,
         5_000,
         10_000,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.15s

operator: core/NumberReplacer, occurrence: 85
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -208,8 +208,7 @@
     help="Request body sizes in bytes (Content-Length if present)",
     label_names=("method", "route"),
     buckets=(
-        100,
-        500,
+        100, 499,
         1_000,
         5_000,
         10_000,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/NumberReplacer, occurrence: 86
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -209,8 +209,7 @@
     label_names=("method", "route"),
     buckets=(
         100,
-        500,
-        1_000,
+        500, 1001,
         5_000,
         10_000,
         50_000,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/NumberReplacer, occurrence: 87
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -209,8 +209,7 @@
     label_names=("method", "route"),
     buckets=(
         100,
-        500,
-        1_000,
+        500, 999,
         5_000,
         10_000,
         50_000,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/NumberReplacer, occurrence: 88
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -210,8 +210,7 @@
     buckets=(
         100,
         500,
-        1_000,
-        5_000,
+        1_000, 5001,
         10_000,
         50_000,
         100_000,
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002449495575Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002450384804Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.29s

operator: core/NumberReplacer, occurrence: 89
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -210,8 +210,7 @@
     buckets=(
         100,
         500,
-        1_000,
-        5_000,
+        1_000, 4999,
         10_000,
         50_000,
         100_000,
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eee0a4cb22dbe3442: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.78s

operator: core/NumberReplacer, occurrence: 90
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -211,8 +211,7 @@
         100,
         500,
         1_000,
-        5_000,
-        10_000,
+        5_000, 10001,
         50_000,
         100_000,
         500_000,
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T005815688158Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T005816577821Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.31s

operator: core/NumberReplacer, occurrence: 91
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -211,8 +211,7 @@
         100,
         500,
         1_000,
-        5_000,
-        10_000,
+        5_000, 9999,
         50_000,
         100_000,
         500_000,
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T141623709206Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T141624552370Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.40s

operator: core/NumberReplacer, occurrence: 92
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -212,8 +212,7 @@
         500,
         1_000,
         5_000,
-        10_000,
-        50_000,
+        10_000, 50001,
         100_000,
         500_000,
         1_000_000,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.26s

operator: core/NumberReplacer, occurrence: 93
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -212,8 +212,7 @@
         500,
         1_000,
         5_000,
-        10_000,
-        50_000,
+        10_000, 49999,
         100_000,
         500_000,
         1_000_000,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.08s

operator: core/NumberReplacer, occurrence: 94
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -213,8 +213,7 @@
         1_000,
         5_000,
         10_000,
-        50_000,
-        100_000,
+        50_000, 100001,
         500_000,
         1_000_000,
         5_000_000,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.99s

operator: core/NumberReplacer, occurrence: 95
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -213,8 +213,7 @@
         1_000,
         5_000,
         10_000,
-        50_000,
-        100_000,
+        50_000, 99999,
         500_000,
         1_000_000,
         5_000_000,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/NumberReplacer, occurrence: 96
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -214,8 +214,7 @@
         5_000,
         10_000,
         50_000,
-        100_000,
-        500_000,
+        100_000, 500001,
         1_000_000,
         5_000_000,
         25_000_000,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.96s

operator: core/NumberReplacer, occurrence: 97
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -214,8 +214,7 @@
         5_000,
         10_000,
         50_000,
-        100_000,
-        500_000,
+        100_000, 499999,
         1_000_000,
         5_000_000,
         25_000_000,
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T182450210745Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T182451077374Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.70s

operator: core/NumberReplacer, occurrence: 98
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -215,8 +215,7 @@
         10_000,
         50_000,
         100_000,
-        500_000,
-        1_000_000,
+        500_000, 1000001,
         5_000_000,
         25_000_000,
         50_000_000,
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e204cae2bffdd28b0: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.72s

operator: core/NumberReplacer, occurrence: 99
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -215,8 +215,7 @@
         10_000,
         50_000,
         100_000,
-        500_000,
-        1_000_000,
+        500_000, 999999,
         5_000_000,
         25_000_000,
         50_000_000,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/NumberReplacer, occurrence: 100
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -216,8 +216,7 @@
         50_000,
         100_000,
         500_000,
-        1_000_000,
-        5_000_000,
+        1_000_000, 5000001,
         25_000_000,
         50_000_000,
     ),
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/NumberReplacer, occurrence: 101
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -216,8 +216,7 @@
         50_000,
         100_000,
         500_000,
-        1_000_000,
-        5_000_000,
+        1_000_000, 4999999,
         25_000_000,
         50_000_000,
     ),
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T000351854104Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T000352772993Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.23s

operator: core/NumberReplacer, occurrence: 102
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -217,8 +217,7 @@
         100_000,
         500_000,
         1_000_000,
-        5_000_000,
-        25_000_000,
+        5_000_000, 25000001,
         50_000_000,
     ),
     counts={},
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.79s

operator: core/NumberReplacer, occurrence: 103
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -217,8 +217,7 @@
         100_000,
         500_000,
         1_000_000,
-        5_000_000,
-        25_000_000,
+        5_000_000, 24999999,
         50_000_000,
     ),
     counts={},
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T021447644031Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T021448577217Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.37s

operator: core/NumberReplacer, occurrence: 104
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -218,8 +218,7 @@
         500_000,
         1_000_000,
         5_000_000,
-        25_000_000,
-        50_000_000,
+        25_000_000, 50000001,
     ),
     counts={},
     sums={},
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/NumberReplacer, occurrence: 105
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -218,8 +218,7 @@
         500_000,
         1_000_000,
         5_000_000,
-        25_000_000,
-        50_000_000,
+        25_000_000, 49999999,
     ),
     counts={},
     sums={},
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/NumberReplacer, occurrence: 106
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -251,7 +251,7 @@
         # decrement in-flight if previously incremented
         key = (route,)
         if INFLIGHT.values.get(key):
-            INFLIGHT.values[key] -= 1
+            INFLIGHT.values[key] -= 2
 
 
 def inc_inflight(route: str) -> None:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.68s

operator: core/NumberReplacer, occurrence: 107
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -251,7 +251,7 @@
         # decrement in-flight if previously incremented
         key = (route,)
         if INFLIGHT.values.get(key):
-            INFLIGHT.values[key] -= 1
+            INFLIGHT.values[key] -= 0
 
 
 def inc_inflight(route: str) -> None:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/NumberReplacer, occurrence: 108
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None or size < 1:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.89s

operator: core/NumberReplacer, occurrence: 109
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None or size < -1:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/RemoveDecorator, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -23,9 +23,6 @@
 from dataclasses import dataclass
 from threading import Lock
 from time import time
-
-
-@dataclass(slots=True)
 class CounterMetric:
     name: str
     help: str

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:17: in <module>

    from observability import (

observability.py:113: in <module>

    REQUESTS = CounterMetric(

E   TypeError: CounterMetric() takes no arguments

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T03:05:02+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:05:02+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T03:05:03+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:05:03+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: CounterMetric() takes no arguments

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.09s

operator: core/RemoveDecorator, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -48,9 +48,6 @@
             )
             lines.append(f"{self.name}{{{label_frag}}} {value}")
         return "\n".join(lines)
-
-
-@dataclass(slots=True)
 class HistogramMetric:
     name: str
     help: str

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:17: in <module>

    from observability import (

observability.py:119: in <module>

    REQUEST_LATENCY = HistogramMetric(

E   TypeError: HistogramMetric() takes no arguments

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T17:54:04+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T17:54:05+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T17:54:06+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T17:54:06+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: HistogramMetric() takes no arguments

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.03s

operator: core/ZeroIterationForLoop, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -41,7 +41,7 @@
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
-        for labels, value in sorted(self.values.items()):
+        for labels, value in []:
             label_frag = ",".join(
                 f"{k}={_quote(v)}"
                 for k, v in zip(self.label_names, labels, strict=True)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.48s

operator: core/ZeroIterationForLoop, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -67,7 +67,7 @@
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
-        for b in self.buckets:
+        for b in []:
             if value <= b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035732035589Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035733165604Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.60s

operator: core/ZeroIterationForLoop, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -83,7 +83,7 @@
         # <name>_count{...} <total>
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} histogram"]
         label_sets = sorted({lbl for (lbl, _le) in self.counts.keys()})
-        for labels in label_sets:
+        for labels in []:
             label_frag = ",".join(
                 f"{k}={_quote(v)}"
                 for k, v in zip(self.label_names, labels, strict=True)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.31s

operator: core/ZeroIterationForLoop, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -89,7 +89,7 @@
                 for k, v in zip(self.label_names, labels, strict=True)
             )
             # Emit stored cumulative counts for each finite bucket
-            for b in self.buckets:
+            for b in []:
                 c = self.counts.get((labels, b), 0)
                 lines.append(
                     f"{self.name}_bucket{{{label_frag},le={_quote(repr(b))}}} {c}"
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T221720819984Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T221721683285Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.90s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC - payload + b"\n"
         return out
 
     def is_watermark_applicable(
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061835060378Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061836026996Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.05s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC + payload - b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.59s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -127,7 +127,7 @@
         if idx == -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
-        start = idx + len(self._MAGIC)
+        start = idx - len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
         end = len(data) if end_nl == -1 else end_nl
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.39s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 3
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -181,7 +181,7 @@
 
     def _mac_hex(self, secret_bytes: bytes, key: str) -> str:
         """Compute HMAC-SHA256 over the contextualized secret and return hex."""
-        hm = hmac.new(key.encode("utf-8"), self._CONTEXT + secret_bytes, hashlib.sha256)
+        hm = hmac.new(key.encode("utf-8"), self._CONTEXT - secret_bytes, hashlib.sha256)
         return hm.hexdigest()
 
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T043222410039Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T043223552968Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.44s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC * payload + b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC + payload * b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -127,7 +127,7 @@
         if idx == -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
-        start = idx + len(self._MAGIC)
+        start = idx * len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
         end = len(data) if end_nl == -1 else end_nl
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.95s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 3
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -181,7 +181,7 @@
 
     def _mac_hex(self, secret_bytes: bytes, key: str) -> str:
         """Compute HMAC-SHA256 over the contextualized secret and return hex."""
-        hm = hmac.new(key.encode("utf-8"), self._CONTEXT + secret_bytes, hashlib.sha256)
+        hm = hmac.new(key.encode("utf-8"), self._CONTEXT * secret_bytes, hashlib.sha256)
         return hm.hexdigest()
 
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.45s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC / payload + b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC + payload / b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -127,7 +127,7 @@
         if idx == -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
-        start = idx + len(self._MAGIC)
+        start = idx / len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
         end = len(data) if end_nl == -1 else end_nl
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011733070699Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011734010597Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.39s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 3
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -181,7 +181,7 @@
 
     def _mac_hex(self, secret_bytes: bytes, key: str) -> str:
         """Compute HMAC-SHA256 over the contextualized secret and return hex."""
-        hm = hmac.new(key.encode("utf-8"), self._CONTEXT + secret_bytes, hashlib.sha256)
+        hm = hmac.new(key.encode("utf-8"), self._CONTEXT / secret_bytes, hashlib.sha256)
         return hm.hexdigest()
 
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.34s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC // payload + b"\n"
         return out
 
     def is_watermark_applicable(
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e2aad559a791f147a: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.45s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC + payload // b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -127,7 +127,7 @@
         if idx == -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
-        start = idx + len(self._MAGIC)
+        start = idx // len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
         end = len(data) if end_nl == -1 else end_nl
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 3
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -181,7 +181,7 @@
 
     def _mac_hex(self, secret_bytes: bytes, key: str) -> str:
         """Compute HMAC-SHA256 over the contextualized secret and return hex."""
-        hm = hmac.new(key.encode("utf-8"), self._CONTEXT + secret_bytes, hashlib.sha256)
+        hm = hmac.new(key.encode("utf-8"), self._CONTEXT // secret_bytes, hashlib.sha256)
         return hm.hexdigest()
 
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.51s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC % payload + b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.46s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC + payload % b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.63s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -127,7 +127,7 @@
         if idx == -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
-        start = idx + len(self._MAGIC)
+        start = idx % len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
         end = len(data) if end_nl == -1 else end_nl
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.27s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 3
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -181,7 +181,7 @@
 
     def _mac_hex(self, secret_bytes: bytes, key: str) -> str:
         """Compute HMAC-SHA256 over the contextualized secret and return hex."""
-        hm = hmac.new(key.encode("utf-8"), self._CONTEXT + secret_bytes, hashlib.sha256)
+        hm = hmac.new(key.encode("utf-8"), self._CONTEXT % secret_bytes, hashlib.sha256)
         return hm.hexdigest()
 
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.39s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC ** payload + b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.41s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC + payload ** b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.84s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -127,7 +127,7 @@
         if idx == -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
-        start = idx + len(self._MAGIC)
+        start = idx ** len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
         end = len(data) if end_nl == -1 else end_nl
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 3
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -181,7 +181,7 @@
 
     def _mac_hex(self, secret_bytes: bytes, key: str) -> str:
         """Compute HMAC-SHA256 over the contextualized secret and return hex."""
-        hm = hmac.new(key.encode("utf-8"), self._CONTEXT + secret_bytes, hashlib.sha256)
+        hm = hmac.new(key.encode("utf-8"), self._CONTEXT ** secret_bytes, hashlib.sha256)
         return hm.hexdigest()
 
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T204442382823Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T204443519366Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 21.47s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC >> payload + b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.17s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC + payload >> b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.52s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -127,7 +127,7 @@
         if idx == -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
-        start = idx + len(self._MAGIC)
+        start = idx >> len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
         end = len(data) if end_nl == -1 else end_nl
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T235459961301Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T235500865944Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.44s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 3
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -181,7 +181,7 @@
 
     def _mac_hex(self, secret_bytes: bytes, key: str) -> str:
         """Compute HMAC-SHA256 over the contextualized secret and return hex."""
-        hm = hmac.new(key.encode("utf-8"), self._CONTEXT + secret_bytes, hashlib.sha256)
+        hm = hmac.new(key.encode("utf-8"), self._CONTEXT >> secret_bytes, hashlib.sha256)
         return hm.hexdigest()
 
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.36s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC << payload + b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.29s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC + payload << b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -127,7 +127,7 @@
         if idx == -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
-        start = idx + len(self._MAGIC)
+        start = idx << len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
         end = len(data) if end_nl == -1 else end_nl
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151447703609Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151448629979Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.25s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 3
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -181,7 +181,7 @@
 
     def _mac_hex(self, secret_bytes: bytes, key: str) -> str:
         """Compute HMAC-SHA256 over the contextualized secret and return hex."""
-        hm = hmac.new(key.encode("utf-8"), self._CONTEXT + secret_bytes, hashlib.sha256)
+        hm = hmac.new(key.encode("utf-8"), self._CONTEXT << secret_bytes, hashlib.sha256)
         return hm.hexdigest()
 
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC | payload + b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.63s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC + payload | b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.17s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -127,7 +127,7 @@
         if idx == -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
-        start = idx + len(self._MAGIC)
+        start = idx | len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
         end = len(data) if end_nl == -1 else end_nl
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T191249095415Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T191249989095Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.63s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 3
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -181,7 +181,7 @@
 
     def _mac_hex(self, secret_bytes: bytes, key: str) -> str:
         """Compute HMAC-SHA256 over the contextualized secret and return hex."""
-        hm = hmac.new(key.encode("utf-8"), self._CONTEXT + secret_bytes, hashlib.sha256)
+        hm = hmac.new(key.encode("utf-8"), self._CONTEXT | secret_bytes, hashlib.sha256)
         return hm.hexdigest()
 
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC & payload + b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.90s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC + payload & b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.47s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -127,7 +127,7 @@
         if idx == -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
-        start = idx + len(self._MAGIC)
+        start = idx & len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
         end = len(data) if end_nl == -1 else end_nl
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 3
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -181,7 +181,7 @@
 
     def _mac_hex(self, secret_bytes: bytes, key: str) -> str:
         """Compute HMAC-SHA256 over the contextualized secret and return hex."""
-        hm = hmac.new(key.encode("utf-8"), self._CONTEXT + secret_bytes, hashlib.sha256)
+        hm = hmac.new(key.encode("utf-8"), self._CONTEXT & secret_bytes, hashlib.sha256)
         return hm.hexdigest()
 
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.17s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC ^ payload + b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.35s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -102,7 +102,7 @@
         out = data
         if not out.endswith(b"\n"):
             out += b"\n"
-        out += self._MAGIC + payload + b"\n"
+        out += self._MAGIC + payload ^ b"\n"
         return out
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.47s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -127,7 +127,7 @@
         if idx == -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
-        start = idx + len(self._MAGIC)
+        start = idx ^ len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
         end = len(data) if end_nl == -1 else end_nl
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 3
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -181,7 +181,7 @@
 
     def _mac_hex(self, secret_bytes: bytes, key: str) -> str:
         """Compute HMAC-SHA256 over the contextualized secret and return hex."""
-        hm = hmac.new(key.encode("utf-8"), self._CONTEXT + secret_bytes, hashlib.sha256)
+        hm = hmac.new(key.encode("utf-8"), self._CONTEXT ^ secret_bytes, hashlib.sha256)
         return hm.hexdigest()
 
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T211341377387Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T211342421245Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.61s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -78,7 +78,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str + None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -79,7 +79,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.00s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -108,7 +108,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bool:
         return True
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ed51c8396a94e3ee5: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.60s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -78,7 +78,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str - None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.58s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -79,7 +79,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.97s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -108,7 +108,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.47s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -78,7 +78,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str * None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T140921380706Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T140922435063Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.65s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -79,7 +79,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.29s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -108,7 +108,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -78,7 +78,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str / None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e37eb9b6d2ce341b9: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.56s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -79,7 +79,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.67s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -108,7 +108,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -78,7 +78,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str // None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T211214801802Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T211215876125Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 21.61s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -79,7 +79,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -108,7 +108,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bool:
         return True
 
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061941469797Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061942343936Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.88s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -78,7 +78,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str % None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042629347829Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042630374551Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.68s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -79,7 +79,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -108,7 +108,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -78,7 +78,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ** None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.00s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -79,7 +79,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.83s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -108,7 +108,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -78,7 +78,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str >> None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.31s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -79,7 +79,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
...F.....F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e6851c30e8ed5ee31: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 20.32s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -108,7 +108,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bool:
         return True
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T173107120465Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T173107991813Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.38s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -78,7 +78,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str << None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.48s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -79,7 +79,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.08s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -108,7 +108,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.11s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -78,7 +78,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str & None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.69s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -79,7 +79,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 26.40s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -108,7 +108,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.74s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -78,7 +78,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ^ None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.00s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -79,7 +79,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033644419145Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033645461945Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.38s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -108,7 +108,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bool:
         return True
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1f97ab0eeefebf82: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.62s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -124,7 +124,7 @@
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
-        if idx == -1:
+        if idx != -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
         start = idx + len(self._MAGIC)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.11s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -130,7 +130,7 @@
         start = idx + len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
-        end = len(data) if end_nl == -1 else end_nl
+        end = len(data) if end_nl != -1 else end_nl
         b64_payload = data[start:end].strip()
         if not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.00s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -141,7 +141,7 @@
         except Exception as exc:  # broad: malformed or tampered
             raise SecretNotFoundError("Malformed watermark payload") from exc
 
-        if not (isinstance(payload, dict) and payload.get("v") == 1):
+        if not (isinstance(payload, dict) and payload.get("v") != 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
         if payload.get("alg") != "HMAC-SHA256":
             raise WatermarkingError(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -124,7 +124,7 @@
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
-        if idx == -1:
+        if idx < -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
         start = idx + len(self._MAGIC)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.63s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -130,7 +130,7 @@
         start = idx + len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
-        end = len(data) if end_nl == -1 else end_nl
+        end = len(data) if end_nl < -1 else end_nl
         b64_payload = data[start:end].strip()
         if not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -141,7 +141,7 @@
         except Exception as exc:  # broad: malformed or tampered
             raise SecretNotFoundError("Malformed watermark payload") from exc
 
-        if not (isinstance(payload, dict) and payload.get("v") == 1):
+        if not (isinstance(payload, dict) and payload.get("v") < 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
         if payload.get("alg") != "HMAC-SHA256":
             raise WatermarkingError(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.26s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -124,7 +124,7 @@
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
-        if idx == -1:
+        if idx <= -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
         start = idx + len(self._MAGIC)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.18s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -130,7 +130,7 @@
         start = idx + len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
-        end = len(data) if end_nl == -1 else end_nl
+        end = len(data) if end_nl <= -1 else end_nl
         b64_payload = data[start:end].strip()
         if not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -141,7 +141,7 @@
         except Exception as exc:  # broad: malformed or tampered
             raise SecretNotFoundError("Malformed watermark payload") from exc
 
-        if not (isinstance(payload, dict) and payload.get("v") == 1):
+        if not (isinstance(payload, dict) and payload.get("v") <= 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
         if payload.get("alg") != "HMAC-SHA256":
             raise WatermarkingError(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -124,7 +124,7 @@
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
-        if idx == -1:
+        if idx > -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
         start = idx + len(self._MAGIC)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T060447697308Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T060448580786Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.48s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -130,7 +130,7 @@
         start = idx + len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
-        end = len(data) if end_nl == -1 else end_nl
+        end = len(data) if end_nl > -1 else end_nl
         b64_payload = data[start:end].strip()
         if not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054920477317Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054921392657Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.31s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -141,7 +141,7 @@
         except Exception as exc:  # broad: malformed or tampered
             raise SecretNotFoundError("Malformed watermark payload") from exc
 
-        if not (isinstance(payload, dict) and payload.get("v") == 1):
+        if not (isinstance(payload, dict) and payload.get("v") > 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
         if payload.get("alg") != "HMAC-SHA256":
             raise WatermarkingError(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.41s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -124,7 +124,7 @@
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
-        if idx == -1:
+        if idx >= -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
         start = idx + len(self._MAGIC)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -130,7 +130,7 @@
         start = idx + len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
-        end = len(data) if end_nl == -1 else end_nl
+        end = len(data) if end_nl >= -1 else end_nl
         b64_payload = data[start:end].strip()
         if not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.31s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -141,7 +141,7 @@
         except Exception as exc:  # broad: malformed or tampered
             raise SecretNotFoundError("Malformed watermark payload") from exc
 
-        if not (isinstance(payload, dict) and payload.get("v") == 1):
+        if not (isinstance(payload, dict) and payload.get("v") >= 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
         if payload.get("alg") != "HMAC-SHA256":
             raise WatermarkingError(
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212631568314Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212632591526Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 22.75s

operator: core/ReplaceComparisonOperator_Eq_Is, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -124,7 +124,7 @@
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
-        if idx == -1:
+        if idx is -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
         start = idx + len(self._MAGIC)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.48s

operator: core/ReplaceComparisonOperator_Eq_Is, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -130,7 +130,7 @@
         start = idx + len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
-        end = len(data) if end_nl == -1 else end_nl
+        end = len(data) if end_nl is -1 else end_nl
         b64_payload = data[start:end].strip()
         if not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ReplaceComparisonOperator_Eq_IsNot, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -124,7 +124,7 @@
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
-        if idx == -1:
+        if idx is not -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
         start = idx + len(self._MAGIC)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042502098644Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042503532452Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 21.48s

operator: core/ReplaceComparisonOperator_Eq_IsNot, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -130,7 +130,7 @@
         start = idx + len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
-        end = len(data) if end_nl == -1 else end_nl
+        end = len(data) if end_nl is not -1 else end_nl
         b64_payload = data[start:end].strip()
         if not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035814336065Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035815328769Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.92s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -143,7 +143,7 @@
 
         if not (isinstance(payload, dict) and payload.get("v") == 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
-        if payload.get("alg") != "HMAC-SHA256":
+        if payload.get("alg") == "HMAC-SHA256":
             raise WatermarkingError(
                 f"Unsupported MAC algorithm: {payload.get('alg')!r}"
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.02s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -143,7 +143,7 @@
 
         if not (isinstance(payload, dict) and payload.get("v") == 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
-        if payload.get("alg") != "HMAC-SHA256":
+        if payload.get("alg") < "HMAC-SHA256":
             raise WatermarkingError(
                 f"Unsupported MAC algorithm: {payload.get('alg')!r}"
             )
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155512428361Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155513347631Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.44s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -143,7 +143,7 @@
 
         if not (isinstance(payload, dict) and payload.get("v") == 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
-        if payload.get("alg") != "HMAC-SHA256":
+        if payload.get("alg") <= "HMAC-SHA256":
             raise WatermarkingError(
                 f"Unsupported MAC algorithm: {payload.get('alg')!r}"
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.40s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -143,7 +143,7 @@
 
         if not (isinstance(payload, dict) and payload.get("v") == 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
-        if payload.get("alg") != "HMAC-SHA256":
+        if payload.get("alg") > "HMAC-SHA256":
             raise WatermarkingError(
                 f"Unsupported MAC algorithm: {payload.get('alg')!r}"
             )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T021225566639Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T021226410680Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.20s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -143,7 +143,7 @@
 
         if not (isinstance(payload, dict) and payload.get("v") == 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
-        if payload.get("alg") != "HMAC-SHA256":
+        if payload.get("alg") >= "HMAC-SHA256":
             raise WatermarkingError(
                 f"Unsupported MAC algorithm: {payload.get('alg')!r}"
             )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T144528743775Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T144529604323Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.43s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -143,7 +143,7 @@
 
         if not (isinstance(payload, dict) and payload.get("v") == 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
-        if payload.get("alg") != "HMAC-SHA256":
+        if payload.get("alg") is "HMAC-SHA256":
             raise WatermarkingError(
                 f"Unsupported MAC algorithm: {payload.get('alg')!r}"
             )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142156476519Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142157469575Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.33s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -143,7 +143,7 @@
 
         if not (isinstance(payload, dict) and payload.get("v") == 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
-        if payload.get("alg") != "HMAC-SHA256":
+        if payload.get("alg") is not "HMAC-SHA256":
             raise WatermarkingError(
                 f"Unsupported MAC algorithm: {payload.get('alg')!r}"
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.97s

operator: core/ReplaceUnaryOperator_USub_UAdd, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -124,7 +124,7 @@
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
-        if idx == -1:
+        if idx == +1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
         start = idx + len(self._MAGIC)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceUnaryOperator_USub_UAdd, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -130,7 +130,7 @@
         start = idx + len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
-        end = len(data) if end_nl == -1 else end_nl
+        end = len(data) if end_nl == +1 else end_nl
         b64_payload = data[start:end].strip()
         if not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.60s

operator: core/ReplaceUnaryOperator_USub_Invert, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -124,7 +124,7 @@
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
-        if idx == -1:
+        if idx == ~1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
         start = idx + len(self._MAGIC)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.74s

operator: core/ReplaceUnaryOperator_USub_Invert, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -130,7 +130,7 @@
         start = idx + len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
-        end = len(data) if end_nl == -1 else end_nl
+        end = len(data) if end_nl == ~1 else end_nl
         b64_payload = data[start:end].strip()
         if not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.49s

operator: core/ReplaceUnaryOperator_USub_Not, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -124,7 +124,7 @@
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
-        if idx == -1:
+        if idx == not 1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
         start = idx + len(self._MAGIC)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.54s

operator: core/ReplaceUnaryOperator_USub_Not, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -130,7 +130,7 @@
         start = idx + len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
-        end = len(data) if end_nl == -1 else end_nl
+        end = len(data) if end_nl == not 1 else end_nl
         b64_payload = data[start:end].strip()
         if not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T052506725068Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T052507606376Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.57s

operator: core/ReplaceUnaryOperator_Delete_USub, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -124,7 +124,7 @@
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
-        if idx == -1:
+        if idx == 1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
         start = idx + len(self._MAGIC)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.96s

operator: core/ReplaceUnaryOperator_Delete_USub, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -130,7 +130,7 @@
         start = idx + len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
-        end = len(data) if end_nl == -1 else end_nl
+        end = len(data) if end_nl == 1 else end_nl
         b64_payload = data[start:end].strip()
         if not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -87,7 +87,7 @@
         ignored by this method.
         """
         data = load_pdf_bytes(pdf)
-        if not secret:
+        if  secret:
             raise ValueError("Secret must be a non-empty string")
         if not isinstance(key, str) or not key:
             raise ValueError("Key must be a non-empty string")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.47s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -89,7 +89,7 @@
         data = load_pdf_bytes(pdf)
         if not secret:
             raise ValueError("Secret must be a non-empty string")
-        if not isinstance(key, str) or not key:
+        if  isinstance(key, str) or not key:
             raise ValueError("Key must be a non-empty string")
 
         payload = self._build_payload(secret, key)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.95s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -89,7 +89,7 @@
         data = load_pdf_bytes(pdf)
         if not secret:
             raise ValueError("Secret must be a non-empty string")
-        if not isinstance(key, str) or not key:
+        if not isinstance(key, str) or  key:
             raise ValueError("Key must be a non-empty string")
 
         payload = self._build_payload(secret, key)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 3
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -100,7 +100,7 @@
         # We do not alter the original bytes to preserve determinism and
         # avoid invalidating existing xref tables.
         out = data
-        if not out.endswith(b"\n"):
+        if  out.endswith(b"\n"):
             out += b"\n"
         out += self._MAGIC + payload + b"\n"
         return out
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e48954d789193e41c: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.73s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 4
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -120,7 +120,7 @@
         does not validate under the given key.
         """
         data = load_pdf_bytes(pdf)
-        if not isinstance(key, str) or not key:
+        if  isinstance(key, str) or not key:
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.73s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 5
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -120,7 +120,7 @@
         does not validate under the given key.
         """
         data = load_pdf_bytes(pdf)
-        if not isinstance(key, str) or not key:
+        if not isinstance(key, str) or  key:
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 6
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -132,7 +132,7 @@
         end_nl = data.find(b"\n", start)
         end = len(data) if end_nl == -1 else end_nl
         b64_payload = data[start:end].strip()
-        if not b64_payload:
+        if  b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
 
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.36s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 7
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -141,7 +141,7 @@
         except Exception as exc:  # broad: malformed or tampered
             raise SecretNotFoundError("Malformed watermark payload") from exc
 
-        if not (isinstance(payload, dict) and payload.get("v") == 1):
+        if  (isinstance(payload, dict) and payload.get("v") == 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
         if payload.get("alg") != "HMAC-SHA256":
             raise WatermarkingError(
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150610823992Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150611701041Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.37s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 8
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -156,7 +156,7 @@
             raise SecretNotFoundError("Invalid payload fields") from exc
 
         expected = self._mac_hex(secret_bytes, key)
-        if not hmac.compare_digest(mac_hex, expected):
+        if  hmac.compare_digest(mac_hex, expected):
             raise InvalidKeyError("Provided key failed to authenticate the watermark")
 
         return secret_bytes.decode("utf-8")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -87,7 +87,7 @@
         ignored by this method.
         """
         data = load_pdf_bytes(pdf)
-        if not secret:
+        if not not secret:
             raise ValueError("Secret must be a non-empty string")
         if not isinstance(key, str) or not key:
             raise ValueError("Key must be a non-empty string")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -89,7 +89,7 @@
         data = load_pdf_bytes(pdf)
         if not secret:
             raise ValueError("Secret must be a non-empty string")
-        if not isinstance(key, str) or not key:
+        if not not isinstance(key, str) or not key:
             raise ValueError("Key must be a non-empty string")
 
         payload = self._build_payload(secret, key)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.41s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -100,7 +100,7 @@
         # We do not alter the original bytes to preserve determinism and
         # avoid invalidating existing xref tables.
         out = data
-        if not out.endswith(b"\n"):
+        if not not out.endswith(b"\n"):
             out += b"\n"
         out += self._MAGIC + payload + b"\n"
         return out
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.43s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -120,7 +120,7 @@
         does not validate under the given key.
         """
         data = load_pdf_bytes(pdf)
-        if not isinstance(key, str) or not key:
+        if not not isinstance(key, str) or not key:
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.88s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -124,7 +124,7 @@
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
-        if idx == -1:
+        if not idx == -1:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
         start = idx + len(self._MAGIC)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T005223710191Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T005224600200Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.14s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -130,7 +130,7 @@
         start = idx + len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
-        end = len(data) if end_nl == -1 else end_nl
+        end = len(data) if not end_nl == -1 else end_nl
         b64_payload = data[start:end].strip()
         if not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041319269114Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041320235702Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 20.85s

operator: core/AddNot, occurrence: 6
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -132,7 +132,7 @@
         end_nl = data.find(b"\n", start)
         end = len(data) if end_nl == -1 else end_nl
         b64_payload = data[start:end].strip()
-        if not b64_payload:
+        if not not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
 
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/AddNot, occurrence: 7
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -141,7 +141,7 @@
         except Exception as exc:  # broad: malformed or tampered
             raise SecretNotFoundError("Malformed watermark payload") from exc
 
-        if not (isinstance(payload, dict) and payload.get("v") == 1):
+        if not not (isinstance(payload, dict) and payload.get("v") == 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
         if payload.get("alg") != "HMAC-SHA256":
             raise WatermarkingError(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/AddNot, occurrence: 8
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -143,7 +143,7 @@
 
         if not (isinstance(payload, dict) and payload.get("v") == 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
-        if payload.get("alg") != "HMAC-SHA256":
+        if not payload.get("alg") != "HMAC-SHA256":
             raise WatermarkingError(
                 f"Unsupported MAC algorithm: {payload.get('alg')!r}"
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/AddNot, occurrence: 9
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -156,7 +156,7 @@
             raise SecretNotFoundError("Invalid payload fields") from exc
 
         expected = self._mac_hex(secret_bytes, key)
-        if not hmac.compare_digest(mac_hex, expected):
+        if not not hmac.compare_digest(mac_hex, expected):
             raise InvalidKeyError("Provided key failed to authenticate the watermark")
 
         return secret_bytes.decode("utf-8")
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e07d40a7e01619a6c: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.12s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -110,7 +110,7 @@
         pdf: PdfSource,
         position: str | None = None,
     ) -> bool:
-        return True
+        return False
 
     def read_secret(self, pdf, key: str) -> str:
         """Extract the secret if present and authenticated by ``key``.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceTrueWithFalse, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -176,7 +176,7 @@
             "secret": base64.b64encode(secret_bytes).decode("ascii"),
         }
         # Compact JSON for determinism
-        j = json.dumps(obj, separators=(",", ":"), ensure_ascii=True).encode("utf-8")
+        j = json.dumps(obj, separators=(",", ":"), ensure_ascii=False).encode("utf-8")
         return base64.urlsafe_b64encode(j)
 
     def _mac_hex(self, secret_bytes: bytes, key: str) -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.58s

operator: core/ReplaceAndWithOr, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -141,7 +141,7 @@
         except Exception as exc:  # broad: malformed or tampered
             raise SecretNotFoundError("Malformed watermark payload") from exc
 
-        if not (isinstance(payload, dict) and payload.get("v") == 1):
+        if not (isinstance(payload, dict) or payload.get("v") == 1):
             raise SecretNotFoundError("Unsupported watermark version or format")
         if payload.get("alg") != "HMAC-SHA256":
             raise WatermarkingError(
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e26514eb9f82b4994: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.81s

operator: core/ReplaceOrWithAnd, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -89,7 +89,7 @@
         data = load_pdf_bytes(pdf)
         if not secret:
             raise ValueError("Secret must be a non-empty string")
-        if not isinstance(key, str) or not key:
+        if not isinstance(key, str) and not key:
             raise ValueError("Key must be a non-empty string")
 
         payload = self._build_payload(secret, key)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T205245781932Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T205247279909Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 23.10s

operator: core/ReplaceOrWithAnd, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -120,7 +120,7 @@
         does not validate under the given key.
         """
         data = load_pdf_bytes(pdf)
-        if not isinstance(key, str) or not key:
+        if not isinstance(key, str) and not key:
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.00s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -138,7 +138,7 @@
         try:
             payload_json = base64.urlsafe_b64decode(b64_payload)
             payload = json.loads(payload_json)
-        except Exception as exc:  # broad: malformed or tampered
+        except CosmicRayTestingException as exc:  # broad: malformed or tampered
             raise SecretNotFoundError("Malformed watermark payload") from exc
 
         if not (isinstance(payload, dict) and payload.get("v") == 1):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.58s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -152,7 +152,7 @@
             mac_hex = str(payload["mac"])  # stored as hex string
             secret_b64 = str(payload["secret"]).encode("ascii")
             secret_bytes = base64.b64decode(secret_b64)
-        except Exception as exc:
+        except CosmicRayTestingException as exc:
             raise SecretNotFoundError("Invalid payload fields") from exc
 
         expected = self._mac_hex(secret_bytes, key)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.95s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -124,7 +124,7 @@
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
-        if idx == -1:
+        if idx == - 2:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
         start = idx + len(self._MAGIC)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.17s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -124,7 +124,7 @@
             raise ValueError("Key must be a non-empty string")
 
         idx = data.rfind(self._MAGIC)
-        if idx == -1:
+        if idx == - 0:
             raise SecretNotFoundError("No AddAfterEOF watermark found")
 
         start = idx + len(self._MAGIC)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ea47b6ee23269595f: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.87s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -130,7 +130,7 @@
         start = idx + len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
-        end = len(data) if end_nl == -1 else end_nl
+        end = len(data) if end_nl == - 2 else end_nl
         b64_payload = data[start:end].strip()
         if not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e463646957006aba2: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.80s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -130,7 +130,7 @@
         start = idx + len(self._MAGIC)
         # Payload ends at the next newline or EOF
         end_nl = data.find(b"\n", start)
-        end = len(data) if end_nl == -1 else end_nl
+        end = len(data) if end_nl == - 0 else end_nl
         b64_payload = data[start:end].strip()
         if not b64_payload:
             raise SecretNotFoundError("Found marker but empty payload")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.34s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -141,7 +141,7 @@
         except Exception as exc:  # broad: malformed or tampered
             raise SecretNotFoundError("Malformed watermark payload") from exc
 
-        if not (isinstance(payload, dict) and payload.get("v") == 1):
+        if not (isinstance(payload, dict) and payload.get("v") == 2):
             raise SecretNotFoundError("Unsupported watermark version or format")
         if payload.get("alg") != "HMAC-SHA256":
             raise WatermarkingError(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -141,7 +141,7 @@
         except Exception as exc:  # broad: malformed or tampered
             raise SecretNotFoundError("Malformed watermark payload") from exc
 
-        if not (isinstance(payload, dict) and payload.get("v") == 1):
+        if not (isinstance(payload, dict) and payload.get("v") == 0):
             raise SecretNotFoundError("Unsupported watermark version or format")
         if payload.get("alg") != "HMAC-SHA256":
             raise WatermarkingError(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -170,7 +170,7 @@
         secret_bytes = secret.encode("utf-8")
         mac_hex = self._mac_hex(secret_bytes, key)
         obj = {
-            "v": 1,
+            "v": 2,
             "alg": "HMAC-SHA256",
             "mac": mac_hex,
             "secret": base64.b64encode(secret_bytes).decode("ascii"),
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.74s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -170,7 +170,7 @@
         secret_bytes = secret.encode("utf-8")
         mac_hex = self._mac_hex(secret_bytes, key)
         obj = {
-            "v": 1,
+            "v": 0,
             "alg": "HMAC-SHA256",
             "mac": mac_hex,
             "secret": base64.b64encode(secret_bytes).decode("ascii"),
...F.....FFF.F                                                           [100%]
operator: core/RemoveDecorator, occurrence: 0
--- mutation diff ---
--- aold methods\add_after_eof.py
+++ bold methods\add_after_eof.py
@@ -61,12 +61,6 @@
     # Constants
     _MAGIC: Final[bytes] = b"\n%%WM-ADD-AFTER-EOF:v1\n"
     _CONTEXT: Final[bytes] = b"wm:add-after-eof:v1:"
-
-    # ---------------------
-    # Public API overrides
-    # ---------------------
-
-    @staticmethod
     def get_usage() -> str:
         return (
             "Toy method that appends a watermark record after the PDF EOF. "
...F.....F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee69181ee2b4ff442: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 20.21s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] + None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] - None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T185831661147Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T185832587381Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.70s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] * None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e3bb5480ae77e8512: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.87s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] / None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T185706346074Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T185707351999Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.06s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] // None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] % None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T224806282449Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T224807160338Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.42s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] ** None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] >> None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T022658622290Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T022659496463Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.39s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] << None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] & None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] ^ None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.63s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if __name__ != "__main__":
     raise SystemExit(main())
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if __name__ < "__main__":
     raise SystemExit(main())
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if __name__ <= "__main__":
     raise SystemExit(main())
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.97s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if __name__ > "__main__":
     raise SystemExit(main())
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T015355460824Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T015356391256Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.29s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if __name__ >= "__main__":
     raise SystemExit(main())
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.59s

operator: core/ReplaceComparisonOperator_Eq_Is, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if __name__ is "__main__":
     raise SystemExit(main())
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.34s

operator: core/ReplaceComparisonOperator_Eq_IsNot, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if __name__ is not "__main__":
     raise SystemExit(main())
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e5e1aedd441ec4345: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.77s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -63,7 +63,7 @@
 
 
 def _resolve_secret(args: argparse.Namespace) -> str:
-    if args.secret is not None:
+    if args.secret is None:
         return args.secret
     if args.secret_file is not None:
         return _read_text_from_file(args.secret_file)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055702591624Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055703586068Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.63s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 1
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -65,7 +65,7 @@
 def _resolve_secret(args: argparse.Namespace) -> str:
     if args.secret is not None:
         return args.secret
-    if args.secret_file is not None:
+    if args.secret_file is None:
         return _read_text_from_file(args.secret_file)
     if args.secret_stdin:
         return _read_text_from_stdin()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 2
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -74,7 +74,7 @@
 
 
 def _resolve_key(args: argparse.Namespace) -> str:
-    if args.key is not None:
+    if args.key is None:
         return args.key
     if args.key_file is not None:
         return _read_text_from_file(args.key_file).strip("\n\r")
...F.....F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e057f9667c873b382: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 22.72s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 3
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -76,7 +76,7 @@
 def _resolve_key(args: argparse.Namespace) -> str:
     if args.key is not None:
         return args.key
-    if args.key_file is not None:
+    if args.key_file is None:
         return _read_text_from_file(args.key_file).strip("\n\r")
     if args.key_stdin:
         return _read_text_from_stdin().strip("\n\r")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.32s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 4
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -228,7 +228,7 @@
 
 def main(argv: Iterable[str] | None = None) -> int:
     parser = build_parser()
-    args = parser.parse_args(list(argv) if argv is not None else None)
+    args = parser.parse_args(list(argv) if argv is None else None)
 
     try:
         return int(args.func(args))
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -57,7 +57,7 @@
 
 def _read_text_from_stdin() -> str:
     data = sys.stdin.read()
-    if not data:
+    if  data:
         raise ValueError("No data received on stdin")
     return data
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -111,7 +111,7 @@
 def cmd_embed(args: argparse.Namespace) -> int:
     key = _resolve_key(args)
     secret = _resolve_secret(args)
-    if not is_watermarking_applicable(
+    if  is_watermarking_applicable(
         method=args.method, pdf=args.input, position=args.position
     ):
         print(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -57,7 +57,7 @@
 
 def _read_text_from_stdin() -> str:
     data = sys.stdin.read()
-    if not data:
+    if not not data:
         raise ValueError("No data received on stdin")
     return data
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e0941958019bb95cd: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.88s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -63,7 +63,7 @@
 
 
 def _resolve_secret(args: argparse.Namespace) -> str:
-    if args.secret is not None:
+    if not args.secret is not None:
         return args.secret
     if args.secret_file is not None:
         return _read_text_from_file(args.secret_file)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T164027696091Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T164028594021Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.33s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -65,7 +65,7 @@
 def _resolve_secret(args: argparse.Namespace) -> str:
     if args.secret is not None:
         return args.secret
-    if args.secret_file is not None:
+    if not args.secret_file is not None:
         return _read_text_from_file(args.secret_file)
     if args.secret_stdin:
         return _read_text_from_stdin()
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034942049012Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034943051045Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.88s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -67,7 +67,7 @@
         return args.secret
     if args.secret_file is not None:
         return _read_text_from_file(args.secret_file)
-    if args.secret_stdin:
+    if not args.secret_stdin:
         return _read_text_from_stdin()
     # Interactive fallback
     return getpass.getpass("Secret: ")
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T222911002023Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T222911876799Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.88s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -74,7 +74,7 @@
 
 
 def _resolve_key(args: argparse.Namespace) -> str:
-    if args.key is not None:
+    if not args.key is not None:
         return args.key
     if args.key_file is not None:
         return _read_text_from_file(args.key_file).strip("\n\r")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.04s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -76,7 +76,7 @@
 def _resolve_key(args: argparse.Namespace) -> str:
     if args.key is not None:
         return args.key
-    if args.key_file is not None:
+    if not args.key_file is not None:
         return _read_text_from_file(args.key_file).strip("\n\r")
     if args.key_stdin:
         return _read_text_from_stdin().strip("\n\r")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/AddNot, occurrence: 6
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -78,7 +78,7 @@
         return args.key
     if args.key_file is not None:
         return _read_text_from_file(args.key_file).strip("\n\r")
-    if args.key_stdin:
+    if not args.key_stdin:
         return _read_text_from_stdin().strip("\n\r")
     if args.key_prompt:
         return getpass.getpass("Key: ")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/AddNot, occurrence: 7
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -80,7 +80,7 @@
         return _read_text_from_file(args.key_file).strip("\n\r")
     if args.key_stdin:
         return _read_text_from_stdin().strip("\n\r")
-    if args.key_prompt:
+    if not args.key_prompt:
         return getpass.getpass("Key: ")
     # If nothing provided, still prompt (safer default)
     return getpass.getpass("Key: ")
...F.........F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eccca22db9a747bdc: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 22.13s

operator: core/AddNot, occurrence: 8
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -99,7 +99,7 @@
 
 def cmd_explore(args: argparse.Namespace) -> int:
     tree = explore_pdf(args.input)
-    if args.out:
+    if not args.out:
         with open(args.out, "w", encoding="utf-8") as fh:
             json.dump(tree, fh, indent=2, ensure_ascii=False)
     else:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231019282619Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231020170048Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.39s

operator: core/AddNot, occurrence: 9
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -111,7 +111,7 @@
 def cmd_embed(args: argparse.Namespace) -> int:
     key = _resolve_key(args)
     secret = _resolve_secret(args)
-    if not is_watermarking_applicable(
+    if not not is_watermarking_applicable(
         method=args.method, pdf=args.input, position=args.position
     ):
         print(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/AddNot, occurrence: 10
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -137,7 +137,7 @@
 def cmd_extract(args: argparse.Namespace) -> int:
     key = _resolve_key(args)
     secret = read_watermark(method=args.method, pdf=args.input, key=key)
-    if args.out:
+    if not args.out:
         with open(args.out, "w", encoding="utf-8") as fh:
             fh.write(secret)
         print(f"Wrote secret -> {args.out}")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/AddNot, occurrence: 11
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -228,7 +228,7 @@
 
 def main(argv: Iterable[str] | None = None) -> int:
     parser = build_parser()
-    args = parser.parse_args(list(argv) if argv is not None else None)
+    args = parser.parse_args(list(argv) if not argv is not None else None)
 
     try:
         return int(args.func(args))
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.35s

operator: core/AddNot, occurrence: 12
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if not __name__ == "__main__":
     raise SystemExit(main())
 
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.21s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -157,7 +157,7 @@
     )
     p.add_argument("--version", action="version", version=f"pdfwm {__version__}")
 
-    sub = p.add_subparsers(dest="cmd", required=True)
+    sub = p.add_subparsers(dest="cmd", required=False)
 
     # methods
     p_methods = sub.add_parser("methods", help="List available watermarking methods")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.32s

operator: core/ReplaceFalseWithTrue, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -101,7 +101,7 @@
     tree = explore_pdf(args.input)
     if args.out:
         with open(args.out, "w", encoding="utf-8") as fh:
-            json.dump(tree, fh, indent=2, ensure_ascii=False)
+            json.dump(tree, fh, indent=2, ensure_ascii=True)
     else:
         json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
         print()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.62s

operator: core/ReplaceFalseWithTrue, occurrence: 1
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -103,7 +103,7 @@
         with open(args.out, "w", encoding="utf-8") as fh:
             json.dump(tree, fh, indent=2, ensure_ascii=False)
     else:
-        json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
+        json.dump(tree, sys.stdout, indent=2, ensure_ascii=True)
         print()
     return 0
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -232,7 +232,7 @@
 
     try:
         return int(args.func(args))
-    except FileNotFoundError as e:
+    except CosmicRayTestingException as e:
         print(f"error: {e}", file=sys.stderr)
         return 2
     except ValueError as e:
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034650863379Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034651741610Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.40s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -235,7 +235,7 @@
     except FileNotFoundError as e:
         print(f"error: {e}", file=sys.stderr)
         return 2
-    except ValueError as e:
+    except CosmicRayTestingException as e:
         print(f"error: {e}", file=sys.stderr)
         return 2
     except SecretNotFoundError as e:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171021023043Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171021876828Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.20s

operator: core/ExceptionReplacer, occurrence: 2
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -238,7 +238,7 @@
     except ValueError as e:
         print(f"error: {e}", file=sys.stderr)
         return 2
-    except SecretNotFoundError as e:
+    except CosmicRayTestingException as e:
         print(f"secret not found: {e}", file=sys.stderr)
         return 3
     except InvalidKeyError as e:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/ExceptionReplacer, occurrence: 3
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -241,7 +241,7 @@
     except SecretNotFoundError as e:
         print(f"secret not found: {e}", file=sys.stderr)
         return 3
-    except InvalidKeyError as e:
+    except CosmicRayTestingException as e:
         print(f"invalid key: {e}", file=sys.stderr)
         return 4
     except WatermarkingError as e:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.95s

operator: core/ExceptionReplacer, occurrence: 4
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -244,7 +244,7 @@
     except InvalidKeyError as e:
         print(f"invalid key: {e}", file=sys.stderr)
         return 4
-    except WatermarkingError as e:
+    except CosmicRayTestingException as e:
         print(f"watermarking error: {e}", file=sys.stderr)
         return 5
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -94,7 +94,7 @@
 def cmd_methods(_args: argparse.Namespace) -> int:
     for name in sorted(METHODS):
         print(name)
-    return 0
+    return 1
 
 
 def cmd_explore(args: argparse.Namespace) -> int:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053840391953Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053841236752Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.34s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -94,7 +94,7 @@
 def cmd_methods(_args: argparse.Namespace) -> int:
     for name in sorted(METHODS):
         print(name)
-    return 0
+    return -1
 
 
 def cmd_explore(args: argparse.Namespace) -> int:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -101,7 +101,7 @@
     tree = explore_pdf(args.input)
     if args.out:
         with open(args.out, "w", encoding="utf-8") as fh:
-            json.dump(tree, fh, indent=2, ensure_ascii=False)
+            json.dump(tree, fh, indent= 3, ensure_ascii=False)
     else:
         json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
         print()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -101,7 +101,7 @@
     tree = explore_pdf(args.input)
     if args.out:
         with open(args.out, "w", encoding="utf-8") as fh:
-            json.dump(tree, fh, indent=2, ensure_ascii=False)
+            json.dump(tree, fh, indent= 1, ensure_ascii=False)
     else:
         json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
         print()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.94s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -103,7 +103,7 @@
         with open(args.out, "w", encoding="utf-8") as fh:
             json.dump(tree, fh, indent=2, ensure_ascii=False)
     else:
-        json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
+        json.dump(tree, sys.stdout, indent= 3, ensure_ascii=False)
         print()
     return 0
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -103,7 +103,7 @@
         with open(args.out, "w", encoding="utf-8") as fh:
             json.dump(tree, fh, indent=2, ensure_ascii=False)
     else:
-        json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
+        json.dump(tree, sys.stdout, indent= 1, ensure_ascii=False)
         print()
     return 0
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.35s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -105,7 +105,7 @@
     else:
         json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
         print()
-    return 0
+    return 1
 
 
 def cmd_embed(args: argparse.Namespace) -> int:
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 20.67s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -105,7 +105,7 @@
     else:
         json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
         print()
-    return 0
+    return -1
 
 
 def cmd_embed(args: argparse.Namespace) -> int:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.49s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -118,7 +118,7 @@
             f"Method {args.method} is not applicable on {args.output} at "
             f"{args.position}."
         )
-        return 5
+        return 6
 
     pdf_bytes = apply_watermark(
         method=args.method,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.69s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -118,7 +118,7 @@
             f"Method {args.method} is not applicable on {args.output} at "
             f"{args.position}."
         )
-        return 5
+        return 4
 
     pdf_bytes = apply_watermark(
         method=args.method,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/NumberReplacer, occurrence: 10
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -131,7 +131,7 @@
     with open(args.output, "wb") as fh:
         fh.write(pdf_bytes)
     print(f"Wrote watermarked PDF -> {args.output}")
-    return 0
+    return 1
 
 
 def cmd_extract(args: argparse.Namespace) -> int:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/NumberReplacer, occurrence: 11
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -131,7 +131,7 @@
     with open(args.output, "wb") as fh:
         fh.write(pdf_bytes)
     print(f"Wrote watermarked PDF -> {args.output}")
-    return 0
+    return -1
 
 
 def cmd_extract(args: argparse.Namespace) -> int:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T190615310646Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T190616211378Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.73s

operator: core/NumberReplacer, occurrence: 12
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -143,7 +143,7 @@
         print(f"Wrote secret -> {args.out}")
     else:
         print(secret)
-    return 0
+    return 1
 
 
 # --------------------
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee40cb4752147eb07: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.58s

operator: core/NumberReplacer, occurrence: 13
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -143,7 +143,7 @@
         print(f"Wrote secret -> {args.out}")
     else:
         print(secret)
-    return 0
+    return -1
 
 
 # --------------------
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.92s

operator: core/NumberReplacer, occurrence: 14
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -234,7 +234,7 @@
         return int(args.func(args))
     except FileNotFoundError as e:
         print(f"error: {e}", file=sys.stderr)
-        return 2
+        return 3
     except ValueError as e:
         print(f"error: {e}", file=sys.stderr)
         return 2
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.51s

operator: core/NumberReplacer, occurrence: 15
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -234,7 +234,7 @@
         return int(args.func(args))
     except FileNotFoundError as e:
         print(f"error: {e}", file=sys.stderr)
-        return 2
+        return 1
     except ValueError as e:
         print(f"error: {e}", file=sys.stderr)
         return 2
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T012803602745Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T012804514727Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.24s

operator: core/NumberReplacer, occurrence: 16
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -237,7 +237,7 @@
         return 2
     except ValueError as e:
         print(f"error: {e}", file=sys.stderr)
-        return 2
+        return 3
     except SecretNotFoundError as e:
         print(f"secret not found: {e}", file=sys.stderr)
         return 3
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/NumberReplacer, occurrence: 17
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -237,7 +237,7 @@
         return 2
     except ValueError as e:
         print(f"error: {e}", file=sys.stderr)
-        return 2
+        return 1
     except SecretNotFoundError as e:
         print(f"secret not found: {e}", file=sys.stderr)
         return 3
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.71s

operator: core/NumberReplacer, occurrence: 18
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -240,7 +240,7 @@
         return 2
     except SecretNotFoundError as e:
         print(f"secret not found: {e}", file=sys.stderr)
-        return 3
+        return 4
     except InvalidKeyError as e:
         print(f"invalid key: {e}", file=sys.stderr)
         return 4
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:831: in write

    self._check(file)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:699: in _check

    self.rollover()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:711: in rollover

    newfile.write(file.getvalue())

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'%PDF-1.4\n000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 20.28s

operator: core/NumberReplacer, occurrence: 19
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -240,7 +240,7 @@
         return 2
     except SecretNotFoundError as e:
         print(f"secret not found: {e}", file=sys.stderr)
-        return 3
+        return 2
     except InvalidKeyError as e:
         print(f"invalid key: {e}", file=sys.stderr)
         return 4
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.68s

operator: core/NumberReplacer, occurrence: 20
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -243,7 +243,7 @@
         return 3
     except InvalidKeyError as e:
         print(f"invalid key: {e}", file=sys.stderr)
-        return 4
+        return 5
     except WatermarkingError as e:
         print(f"watermarking error: {e}", file=sys.stderr)
         return 5
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e455c83066fde8c3e: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.31s

operator: core/NumberReplacer, occurrence: 21
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -243,7 +243,7 @@
         return 3
     except InvalidKeyError as e:
         print(f"invalid key: {e}", file=sys.stderr)
-        return 4
+        return 3
     except WatermarkingError as e:
         print(f"watermarking error: {e}", file=sys.stderr)
         return 5
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/NumberReplacer, occurrence: 22
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -246,7 +246,7 @@
         return 4
     except WatermarkingError as e:
         print(f"watermarking error: {e}", file=sys.stderr)
-        return 5
+        return 6
 
 
 if __name__ == "__main__":
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T050813628741Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T050814608518Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.64s

operator: core/NumberReplacer, occurrence: 23
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -246,7 +246,7 @@
         return 4
     except WatermarkingError as e:
         print(f"watermarking error: {e}", file=sys.stderr)
-        return 5
+        return 4
 
 
 if __name__ == "__main__":
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.42s

operator: core/ZeroIterationForLoop, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -92,7 +92,7 @@
 
 
 def cmd_methods(_args: argparse.Namespace) -> int:
-    for name in sorted(METHODS):
+    for name in []:
         print(name)
     return 0
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.35s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 - 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.93s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 * 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.93s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 / 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.59s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 // 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
...F.........F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:831: in write

    self._check(file)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:699: in _check

    self.rollover()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:711: in rollover

    newfile.write(file.getvalue())

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'%PDF-1.4\n000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e190bbba64e62d682: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.64s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 % 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T200116853357Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T200117837307Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.70s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 ** 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151528613298Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151529465727Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.29s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 >> 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 << 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.44s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 | 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.01s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 & 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 ^ 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ea44c4bc56465765c: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.79s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height + margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.43s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 + 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height * margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.33s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 * 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T180349727522Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T180351128557Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 23.01s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height / margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 / 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.35s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height // margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.36s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 // 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T051806581502Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T051807499538Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.05s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height % margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.48s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 % 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142640129689Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142641045988Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.41s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height ** margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 ** 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
...F.....F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ecf27e5128d6e01df: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 20.32s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height >> margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 >> 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.96s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height << margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001218728743Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001219607992Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.21s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 << 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003738963433Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003739880084Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.19s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height | margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T163926293742Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T163927195943Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.33s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 | 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.64s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height & margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010014408423Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010015306439Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.29s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 & 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height ^ margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.13s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 ^ 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e018044adebf7c5e6: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.20s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str + None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.90s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161609540906Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161610481290Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.35s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int + None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.05s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 + 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e5c5256f8077a67bc: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.17s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 + 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 + 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.61s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes + None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.99s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes + bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054108978618Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054110009464Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.89s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str - None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.08s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161245393139Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161246330728Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.38s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045011041039Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045011924361Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.51s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int - None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 - 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T183428720914Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T183429699969Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.89s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 - 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.42s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 - 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.97s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes - None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T203536204454Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T203537111907Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.60s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes - bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172454218254Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172455095337Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.35s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str * None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T015731512964Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T015732510866Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.38s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.01s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.39s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int * None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.01s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 * 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.68s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 * 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 * 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.58s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes * None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e814ab849b161828e: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.53s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes * bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str / None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.57s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int / None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T153853260149Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T153854132184Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.20s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 / 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.64s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 / 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.35s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 / 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.54s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes / None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.96s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes / bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T232951883395Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T232952739496Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.37s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str // None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.49s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int // None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T224302845791Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T224303696224Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.58s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 // 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003321136016Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003321997566Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.17s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 // 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.49s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 // 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.80s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes // None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031252956017Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031253874213Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.38s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes // bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str % None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.38s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int % None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 % 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.08s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 % 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e3c6749cb3f68222f: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.72s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 % 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes % None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes % bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.05s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ** None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.97s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.03s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee0d3266162b01387: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.68s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int ** None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035648550770Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035649385231Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.06s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 ** 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.32s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 ** 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.89s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 ** 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.23s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes ** None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes ** bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str >> None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T235342708819Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T235343645464Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.41s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150047117660Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150047959648Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.35s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171421565375Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171422506038Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.48s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int >> None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 22.11s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 >> 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 >> 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.84s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 >> 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.54s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes >> None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.34s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes >> bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str << None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.87s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.04s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T040915845991Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T040916858119Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.65s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int << None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T143637504123Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T143638758610Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.31s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 << 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.92s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 << 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.39s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 << 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.39s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes << None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T213348248585Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T213349073810Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.23s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes << bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str & None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e98b2de62855f1c76: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.96s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T154118254524Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T154119119827Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.40s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055249693094Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055250545977Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.80s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int & None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.58s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 & 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 & 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T225241669275Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T225242585776Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.58s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 & 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035400084492Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035401084854Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.67s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes & None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.51s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes & bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T181942268404Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T181943170557Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.51s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ^ None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054336737971Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054337683345Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.96s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int ^ None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.21s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 ^ 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 22.10s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 ^ 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 ^ 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.37s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes ^ None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034120584584Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034121472508Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.33s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes ^ bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
...F.....FFF.F                                                           [100%]
operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if doc.page_count != 0:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.51s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if doc.page_count != 0:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.02s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if doc.page_count < 0:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e2e814206813d54d4: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.81s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if doc.page_count < 0:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.31s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if doc.page_count <= 0:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.48s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if doc.page_count <= 0:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041450487260Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041451731455Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 21.87s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if doc.page_count > 0:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034347037207Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034348023600Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.16s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if doc.page_count > 0:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if doc.page_count >= 0:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201433179975Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201434095801Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.89s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if doc.page_count >= 0:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if actual == expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.84s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if actual < expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.43s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if actual <= expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.87s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if actual > expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if actual >= expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if actual is expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if actual is not expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.99s

operator: core/ReplaceComparisonOperator_Lt_Eq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if len(b.strip()) == 8:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
...F.....FFF.F                                                           [100%]
operator: core/ReplaceComparisonOperator_Lt_NotEq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if len(b.strip()) != 8:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/ReplaceComparisonOperator_Lt_LtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if len(b.strip()) <= 8:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ReplaceComparisonOperator_Lt_Gt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if len(b.strip()) > 8:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e214f95b1b04e6c65: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.67s

operator: core/ReplaceComparisonOperator_Lt_GtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if len(b.strip()) >= 8:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054525430175Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054526404579Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.31s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count == 0 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T050303056045Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T050303944199Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.80s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count != 0 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e6c5385fb06ee253a: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.75s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count < 0 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 20.10s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count > 0 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.83s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count >= 0 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 or iter_count == 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.95s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 or iter_count != 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010949560547Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010950526058Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.39s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 or iter_count < 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e7beca369256b3483: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.76s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 or iter_count <= 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T232931655316Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T232932643628Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.28s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 or iter_count >= 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054940591987Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054941610348Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.59s

operator: core/ReplaceComparisonOperator_GtE_Eq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if len(out) == self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T230556632047Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T230557495227Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.34s

operator: core/ReplaceComparisonOperator_GtE_NotEq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if len(out) != self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/ReplaceComparisonOperator_GtE_Lt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if len(out) < self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/ReplaceComparisonOperator_GtE_LtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if len(out) <= self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.88s

operator: core/ReplaceComparisonOperator_GtE_Gt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if len(out) > self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceComparisonOperator_GtE_Is, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if len(out) is self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ReplaceComparisonOperator_GtE_IsNot, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if len(out) is not self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.08s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -184,7 +184,7 @@
         doc = pymupdf.open(stream=data, filetype="pdf")
         try:
             manifest_bytes = self._extract_manifest(doc)
-            if manifest_bytes is None:
+            if manifest_bytes is not None:
                 raise SecretNotFoundError("Signed annotation watermark not found")
 
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -77,7 +77,7 @@
         intended_for: str | None = None,
         position: str | None = None,
     ) -> bytes:
-        if not HAS_PYMUPDF:
+        if  HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.51s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -79,7 +79,7 @@
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not secret or not isinstance(secret, str):
+        if  secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
         if not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.34s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -79,7 +79,7 @@
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not secret or not isinstance(secret, str):
+        if not secret or  isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
         if not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.59s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -81,7 +81,7 @@
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
-        if not key or not isinstance(key, str):
+        if  key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         original = load_pdf_bytes(pdf)
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 23.23s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -81,7 +81,7 @@
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
-        if not key or not isinstance(key, str):
+        if not key or  isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         original = load_pdf_bytes(pdf)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         position: str | None = None,
     ) -> bool:
-        if not HAS_PYMUPDF:
+        if  HAS_PYMUPDF:
             return False
         try:
             b = load_pdf_bytes(pdf)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.46s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -175,7 +175,7 @@
         return True
 
     def read_secret(self, pdf: PdfSource, key: str) -> str:
-        if not HAS_PYMUPDF:
+        if  HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053352333290Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053353164217Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.28s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -177,7 +177,7 @@
     def read_secret(self, pdf: PdfSource, key: str) -> str:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not key or not isinstance(key, str):
+        if  key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         data = load_pdf_bytes(pdf)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.16s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -177,7 +177,7 @@
     def read_secret(self, pdf: PdfSource, key: str) -> str:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not key or not isinstance(key, str):
+        if not key or  isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         data = load_pdf_bytes(pdf)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.34s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 9
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -216,7 +216,7 @@
                 raise SecretNotFoundError("Corrupted decrypted payload") from exc
 
             # Validate structure
-            if not (isinstance(payload, dict) and payload.get("secret")):
+            if  (isinstance(payload, dict) and payload.get("secret")):
                 raise SecretNotFoundError("Decrypted payload missing secret field")
 
             # Tamper check: recompute each hashed object
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.70s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -77,7 +77,7 @@
         intended_for: str | None = None,
         position: str | None = None,
     ) -> bytes:
-        if not HAS_PYMUPDF:
+        if not not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T170741762950Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T170742617586Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.09s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -79,7 +79,7 @@
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not secret or not isinstance(secret, str):
+        if not not secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
         if not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
...F.....FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

4 failed, 10 passed, 22 warnings in 22.19s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -81,7 +81,7 @@
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
-        if not key or not isinstance(key, str):
+        if not not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         original = load_pdf_bytes(pdf)
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.25s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if not doc.page_count == 0:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.93s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -129,7 +129,7 @@
             }
             manifest_bytes = json.dumps(manifest, separators=(",", ":")).encode("utf-8")
             try:
-                if (
+                if not (
                     hasattr(doc, "_embfile_names")
                     and self._EMBED_NAME in doc._embfile_names()
                 ):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.41s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -137,7 +137,7 @@
             except Exception as exc:
                 logger.debug("Cleanup of existing embedded file failed: %s", exc)
             try:
-                if hasattr(doc, "_embfile_add"):
+                if not hasattr(doc, "_embfile_add"):
                     doc.embfile_add(
                         self._EMBED_NAME,
                         manifest_bytes,
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053553808087Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053554796492Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.04s

operator: core/AddNot, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         position: str | None = None,
     ) -> bool:
-        if not HAS_PYMUPDF:
+        if not not HAS_PYMUPDF:
             return False
         try:
             b = load_pdf_bytes(pdf)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/AddNot, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -175,7 +175,7 @@
         return True
 
     def read_secret(self, pdf: PdfSource, key: str) -> str:
-        if not HAS_PYMUPDF:
+        if not not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/AddNot, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -177,7 +177,7 @@
     def read_secret(self, pdf: PdfSource, key: str) -> str:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not key or not isinstance(key, str):
+        if not not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         data = load_pdf_bytes(pdf)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/AddNot, occurrence: 9
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -184,7 +184,7 @@
         doc = pymupdf.open(stream=data, filetype="pdf")
         try:
             manifest_bytes = self._extract_manifest(doc)
-            if manifest_bytes is None:
+            if not manifest_bytes is None:
                 raise SecretNotFoundError("Signed annotation watermark not found")
 
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.02s

operator: core/AddNot, occurrence: 10
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if not iter_count <= 0 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T152454336938Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T152455184204Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.13s

operator: core/AddNot, occurrence: 11
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -216,7 +216,7 @@
                 raise SecretNotFoundError("Corrupted decrypted payload") from exc
 
             # Validate structure
-            if not (isinstance(payload, dict) and payload.get("secret")):
+            if not not (isinstance(payload, dict) and payload.get("secret")):
                 raise SecretNotFoundError("Decrypted payload missing secret field")
 
             # Tamper check: recompute each hashed object
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155745887170Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155746816161Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.34s

operator: core/AddNot, occurrence: 12
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if not len(out) >= self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172249183133Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172250135417Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.44s

operator: core/AddNot, occurrence: 13
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -258,7 +258,7 @@
                 )
                 continue
             lower = obj_str.lower()
-            if "/type /catalog" in lower or "/names" in lower:
+            if not "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
             if len(b.strip()) < 8:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054212791597Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T054213736642Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.59s

operator: core/AddNot, occurrence: 14
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if not len(b.strip()) < 8:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/AddNot, occurrence: 15
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if not doc.page_count == 0:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.98s

operator: core/AddNot, occurrence: 16
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -285,7 +285,7 @@
                 logger.debug("Setting annotation flags failed: %s", exc)
             try:
                 # Ensure it is not auto-open
-                if hasattr(annot, "set_open"):
+                if not hasattr(annot, "set_open"):
                     annot.set_open(False)
             except Exception as exc:
                 logger.debug("Setting annotation open state failed: %s", exc)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T141603599388Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T141604499296Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.30s

operator: core/AddNot, occurrence: 17
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -312,7 +312,7 @@
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
-            if hasattr(doc, "_embfile_names"):
+            if not hasattr(doc, "_embfile_names"):
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.66s

operator: core/AddNot, occurrence: 18
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -314,7 +314,7 @@
         try:
             if hasattr(doc, "_embfile_names"):
                 names = doc.embfile_names()
-                if self._EMBED_NAME in names:
+                if not self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
                     if isinstance(file_bytes, bytes | bytearray):
                         return bytes(file_bytes)
...F.....F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1800777982f26693: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 20.34s

operator: core/AddNot, occurrence: 19
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if not isinstance(file_bytes, bytes | bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.21s

operator: core/AddNot, occurrence: 20
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -336,7 +336,7 @@
                     "Referenced object missing (tampered)"
                 ) from None
             lower = obj_str.lower()
-            if "/type /catalog" in lower or "/names" in lower:
+            if not "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/AddNot, occurrence: 21
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if not actual != expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.50s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -36,7 +36,7 @@
 try:  # PyMuPDF is required for all operations of this method
     import pymupdf
 
-    HAS_PYMUPDF = True
+    HAS_PYMUPDF = False
 except Exception:
     HAS_PYMUPDF = False
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T022718652206Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T022719591310Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.30s

operator: core/ReplaceTrueWithFalse, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -172,7 +172,7 @@
                 doc.close()
             except Exception as exc:
                 logging.getLogger(__name__).debug("Closing document failed: %s", exc)
-        return True
+        return False
 
     def read_secret(self, pdf: PdfSource, key: str) -> str:
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.38s

operator: core/ReplaceFalseWithTrue, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -38,7 +38,7 @@
 
     HAS_PYMUPDF = True
 except Exception:
-    HAS_PYMUPDF = False
+    HAS_PYMUPDF = True
 
 
 @dataclass
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.08s

operator: core/ReplaceFalseWithTrue, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -161,7 +161,7 @@
         position: str | None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
-            return False
+            return True
         try:
             b = load_pdf_bytes(pdf)
             doc = pymupdf.open(stream=b, filetype="pdf")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/ReplaceFalseWithTrue, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -166,7 +166,7 @@
             b = load_pdf_bytes(pdf)
             doc = pymupdf.open(stream=b, filetype="pdf")
         except Exception:
-            return False
+            return True
         finally:
             try:
                 doc.close()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.58s

operator: core/ReplaceFalseWithTrue, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -251,7 +251,7 @@
             if len(out) >= self._OBJ_SAMPLE_LIMIT:
                 break
             try:
-                obj_str = doc.xref_object(xref, compressed=False) or ""
+                obj_str = doc.xref_object(xref, compressed=True) or ""
             except Exception as exc:
                 logging.getLogger(__name__).debug(
                     "Reading xref %s failed: %s", xref, exc
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.79s

operator: core/ReplaceFalseWithTrue, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -286,7 +286,7 @@
             try:
                 # Ensure it is not auto-open
                 if hasattr(annot, "set_open"):
-                    annot.set_open(False)
+                    annot.set_open(True)
             except Exception as exc:
                 logger.debug("Setting annotation open state failed: %s", exc)
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.83s

operator: core/ReplaceFalseWithTrue, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -330,7 +330,7 @@
             except Exception:
                 raise WatermarkingError("Malformed object hash entry") from None
             try:
-                obj_str = doc.xref_object(xref, compressed=False) or ""
+                obj_str = doc.xref_object(xref, compressed=True) or ""
             except Exception:
                 raise WatermarkingError(
                     "Referenced object missing (tampered)"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.51s

operator: core/ReplaceAndWithOr, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -131,7 +131,7 @@
             try:
                 if (
                     hasattr(doc, "_embfile_names")
-                    and self._EMBED_NAME in doc._embfile_names()
+                    or self._EMBED_NAME in doc._embfile_names()
                 ):
                     doc._embfile_del(self._EMBED_NAME)
             except Exception as exc:
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T180516839421Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T180517772644Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.88s

operator: core/ReplaceAndWithOr, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -216,7 +216,7 @@
                 raise SecretNotFoundError("Corrupted decrypted payload") from exc
 
             # Validate structure
-            if not (isinstance(payload, dict) and payload.get("secret")):
+            if not (isinstance(payload, dict) or payload.get("secret")):
                 raise SecretNotFoundError("Decrypted payload missing secret field")
 
             # Tamper check: recompute each hashed object
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T162230823028Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T162231711074Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.41s

operator: core/ReplaceOrWithAnd, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -79,7 +79,7 @@
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not secret or not isinstance(secret, str):
+        if not secret and not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
         if not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.50s

operator: core/ReplaceOrWithAnd, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -81,7 +81,7 @@
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
-        if not key or not isinstance(key, str):
+        if not key and not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         original = load_pdf_bytes(pdf)
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 20.62s

operator: core/ReplaceOrWithAnd, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -177,7 +177,7 @@
     def read_secret(self, pdf: PdfSource, key: str) -> str:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not key or not isinstance(key, str):
+        if not key and not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         data = load_pdf_bytes(pdf)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034243283108Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034244219161Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.61s

operator: core/ReplaceOrWithAnd, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 and iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.89s

operator: core/ReplaceOrWithAnd, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -236,7 +236,7 @@
             algorithm=hashes.SHA256(),
             length=32,
             salt=salt,
-            iterations=iter_override or self._PBKDF2_ITER,
+            iterations=iter_override and self._PBKDF2_ITER,
         )
         return kdf.derive(password.encode("utf-8"))
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.01s

operator: core/ReplaceOrWithAnd, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -251,7 +251,7 @@
             if len(out) >= self._OBJ_SAMPLE_LIMIT:
                 break
             try:
-                obj_str = doc.xref_object(xref, compressed=False) or ""
+                obj_str = doc.xref_object(xref, compressed=False) and ""
             except Exception as exc:
                 logging.getLogger(__name__).debug(
                     "Reading xref %s failed: %s", xref, exc
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.98s

operator: core/ReplaceOrWithAnd, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -258,7 +258,7 @@
                 )
                 continue
             lower = obj_str.lower()
-            if "/type /catalog" in lower or "/names" in lower:
+            if "/type /catalog" in lower and "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
             if len(b.strip()) < 8:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.51s

operator: core/ReplaceOrWithAnd, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -330,7 +330,7 @@
             except Exception:
                 raise WatermarkingError("Malformed object hash entry") from None
             try:
-                obj_str = doc.xref_object(xref, compressed=False) or ""
+                obj_str = doc.xref_object(xref, compressed=False) and ""
             except Exception:
                 raise WatermarkingError(
                     "Referenced object missing (tampered)"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.98s

operator: core/ReplaceOrWithAnd, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -336,7 +336,7 @@
                     "Referenced object missing (tampered)"
                 ) from None
             lower = obj_str.lower()
-            if "/type /catalog" in lower or "/names" in lower:
+            if "/type /catalog" in lower and "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.94s

operator: core/ReplaceBreakWithContinue, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -249,7 +249,7 @@
             return out
         for xref in range(1, xref_len):
             if len(out) >= self._OBJ_SAMPLE_LIMIT:
-                break
+                continue
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
             except Exception as exc:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/ReplaceContinueWithBreak, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -256,7 +256,7 @@
                 logging.getLogger(__name__).debug(
                     "Reading xref %s failed: %s", xref, exc
                 )
-                continue
+                break
             lower = obj_str.lower()
             if "/type /catalog" in lower or "/names" in lower:
                 continue
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.36s

operator: core/ReplaceContinueWithBreak, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -259,7 +259,7 @@
                 continue
             lower = obj_str.lower()
             if "/type /catalog" in lower or "/names" in lower:
-                continue
+                break
             b = obj_str.encode("latin-1", "replace")
             if len(b.strip()) < 8:
                 continue
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/ReplaceContinueWithBreak, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -262,7 +262,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             if len(b.strip()) < 8:
-                continue
+                break
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
         return out
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T184905262039Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T184906343042Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.21s

operator: core/ReplaceContinueWithBreak, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -337,7 +337,7 @@
                 ) from None
             lower = obj_str.lower()
             if "/type /catalog" in lower or "/names" in lower:
-                continue
+                break
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
             if actual != expected:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.51s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -37,7 +37,7 @@
     import pymupdf
 
     HAS_PYMUPDF = True
-except Exception:
+except CosmicRayTestingException:
     HAS_PYMUPDF = False
 
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -91,7 +91,7 @@
             doc.close()
             original = load_pdf_bytes(new_doc)
             doc = pymupdf.open(stream=original, filetype="pdf")
-        except Exception as exc:  # fallback: create new doc and append original as raw?
+        except CosmicRayTestingException as exc:  # fallback: create new doc and append original as raw?
             raise WatermarkingError(f"Failed to open PDF: {exc}") from exc
         logger = logging.getLogger(__name__)
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.21s

operator: core/ExceptionReplacer, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -134,7 +134,7 @@
                     and self._EMBED_NAME in doc._embfile_names()
                 ):
                     doc._embfile_del(self._EMBED_NAME)
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logger.debug("Cleanup of existing embedded file failed: %s", exc)
             try:
                 if hasattr(doc, "_embfile_add"):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 22.48s

operator: core/ExceptionReplacer, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -144,7 +144,7 @@
                         filename=self._EMBED_NAME,
                         desc="Tatou signed watermark manifest v1",
                     )
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 raise WatermarkingError(
                     f"Failed to attach watermark embedded file: {exc}"
                 ) from exc
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031621054759Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031621942058Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.32s

operator: core/ExceptionReplacer, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -152,7 +152,7 @@
         finally:
             try:
                 doc.close()
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logging.getLogger(__name__).debug("Closing document failed: %s", exc)
 
     def is_watermark_applicable(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.69s

operator: core/ExceptionReplacer, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -165,7 +165,7 @@
         try:
             b = load_pdf_bytes(pdf)
             doc = pymupdf.open(stream=b, filetype="pdf")
-        except Exception:
+        except CosmicRayTestingException:
             return False
         finally:
             try:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011416225713Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011417171367Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.32s

operator: core/ExceptionReplacer, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -170,7 +170,7 @@
         finally:
             try:
                 doc.close()
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logging.getLogger(__name__).debug("Closing document failed: %s", exc)
         return True
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T221617370295Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T221618259553Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.60s

operator: core/ExceptionReplacer, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -189,7 +189,7 @@
 
             try:
                 manifest = json.loads(manifest_bytes.decode("utf-8"))
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 raise SecretNotFoundError("Malformed watermark manifest") from exc
 
             salt = base64.b64decode(manifest["salt"])
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ExceptionReplacer, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -205,7 +205,7 @@
             aes = AESGCM(key_bytes)
             try:
                 pt = aes.decrypt(nonce, ct, None)
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 raise InvalidKeyError(
                     "Failed to authenticate watermark (key?)"
                 ) from exc
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e267fd059431e9f6f: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.69s

operator: core/ExceptionReplacer, occurrence: 9
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -212,7 +212,7 @@
 
             try:
                 payload = json.loads(pt.decode("utf-8"))
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 raise SecretNotFoundError("Corrupted decrypted payload") from exc
 
             # Validate structure
...F.....F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec19d59134ae98a29: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 20.98s

operator: core/ExceptionReplacer, occurrence: 10
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -245,7 +245,7 @@
         out: list[_ObjectHash] = []
         try:
             xref_len = doc.xref_length()
-        except Exception:
+        except CosmicRayTestingException:
             return out
         for xref in range(1, xref_len):
             if len(out) >= self._OBJ_SAMPLE_LIMIT:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T211035906904Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T211036968791Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.59s

operator: core/ExceptionReplacer, occurrence: 11
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -252,7 +252,7 @@
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logging.getLogger(__name__).debug(
                     "Reading xref %s failed: %s", xref, exc
                 )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.70s

operator: core/ExceptionReplacer, occurrence: 12
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -281,7 +281,7 @@
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
                 flags = 1 | 2 | 32 | 64
                 annot.set_flags(flags)
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
             try:
                 # Ensure it is not auto-open
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.41s

operator: core/ExceptionReplacer, occurrence: 13
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -287,7 +287,7 @@
                 # Ensure it is not auto-open
                 if hasattr(annot, "set_open"):
                     annot.set_open(False)
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logger.debug("Setting annotation open state failed: %s", exc)
             try:
                 annot.set_opacity(0)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.96s

operator: core/ExceptionReplacer, occurrence: 14
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -291,7 +291,7 @@
                 logger.debug("Setting annotation open state failed: %s", exc)
             try:
                 annot.set_opacity(0)
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logger.debug("Setting annotation opacity failed: %s", exc)
             try:
                 # Shrink rectangle to a tiny box
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ExceptionReplacer, occurrence: 15
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -298,7 +298,7 @@
                 r = annot.rect
                 tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
             try:
                 annot.update()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.62s

operator: core/ExceptionReplacer, occurrence: 16
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -302,7 +302,7 @@
                 logger.debug("Shrinking annotation rect failed: %s", exc)
             try:
                 annot.update()
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logger.debug("Annotation update failed: %s", exc)
         except Exception as exc:
             logger.debug("Adding invisible annotation failed: %s", exc)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T013326544083Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T013327498700Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.54s

operator: core/ExceptionReplacer, occurrence: 17
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -304,7 +304,7 @@
                 annot.update()
             except Exception as exc:
                 logger.debug("Annotation update failed: %s", exc)
-        except Exception as exc:
+        except CosmicRayTestingException as exc:
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055427489655Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055428346059Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.67s

operator: core/ExceptionReplacer, occurrence: 18
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -318,7 +318,7 @@
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
                     if isinstance(file_bytes, bytes | bytearray):
                         return bytes(file_bytes)
-        except Exception as exc:
+        except CosmicRayTestingException as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
         return None
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033603474219Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033604472136Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.79s

operator: core/ExceptionReplacer, occurrence: 19
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -327,7 +327,7 @@
             try:
                 xref = int(e.get("xref"))
                 expected = str(e.get("sha256"))
-            except Exception:
+            except CosmicRayTestingException:
                 raise WatermarkingError("Malformed object hash entry") from None
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/ExceptionReplacer, occurrence: 20
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -331,7 +331,7 @@
                 raise WatermarkingError("Malformed object hash entry") from None
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
-            except Exception:
+            except CosmicRayTestingException:
                 raise WatermarkingError(
                     "Referenced object missing (tampered)"
                 ) from None
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171441631592Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T171442506644Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.26s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -54,7 +54,7 @@
 
     # Constants
     _EMBED_NAME: Final[str] = "WM-TATOU-SIGNED-v1.json"
-    _VERSION: Final[int] = 1
+    _VERSION: Final[int] = 2
     _PBKDF2_ITER: Final[int] = 120_000
     _SALT_LEN: Final[int] = 16
     _OBJ_SAMPLE_LIMIT: Final[int] = 12
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.61s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -54,7 +54,7 @@
 
     # Constants
     _EMBED_NAME: Final[str] = "WM-TATOU-SIGNED-v1.json"
-    _VERSION: Final[int] = 1
+    _VERSION: Final[int] = 0
     _PBKDF2_ITER: Final[int] = 120_000
     _SALT_LEN: Final[int] = 16
     _OBJ_SAMPLE_LIMIT: Final[int] = 12
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.80s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -55,7 +55,7 @@
     # Constants
     _EMBED_NAME: Final[str] = "WM-TATOU-SIGNED-v1.json"
     _VERSION: Final[int] = 1
-    _PBKDF2_ITER: Final[int] = 120_000
+    _PBKDF2_ITER: Final[int] = 120001
     _SALT_LEN: Final[int] = 16
     _OBJ_SAMPLE_LIMIT: Final[int] = 12
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.45s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -55,7 +55,7 @@
     # Constants
     _EMBED_NAME: Final[str] = "WM-TATOU-SIGNED-v1.json"
     _VERSION: Final[int] = 1
-    _PBKDF2_ITER: Final[int] = 120_000
+    _PBKDF2_ITER: Final[int] = 119999
     _SALT_LEN: Final[int] = 16
     _OBJ_SAMPLE_LIMIT: Final[int] = 12
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.96s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -56,7 +56,7 @@
     _EMBED_NAME: Final[str] = "WM-TATOU-SIGNED-v1.json"
     _VERSION: Final[int] = 1
     _PBKDF2_ITER: Final[int] = 120_000
-    _SALT_LEN: Final[int] = 16
+    _SALT_LEN: Final[int] = 17
     _OBJ_SAMPLE_LIMIT: Final[int] = 12
 
     @staticmethod
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.07s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -56,7 +56,7 @@
     _EMBED_NAME: Final[str] = "WM-TATOU-SIGNED-v1.json"
     _VERSION: Final[int] = 1
     _PBKDF2_ITER: Final[int] = 120_000
-    _SALT_LEN: Final[int] = 16
+    _SALT_LEN: Final[int] = 15
     _OBJ_SAMPLE_LIMIT: Final[int] = 12
 
     @staticmethod
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T162854440262Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T162855301698Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.15s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -57,7 +57,7 @@
     _VERSION: Final[int] = 1
     _PBKDF2_ITER: Final[int] = 120_000
     _SALT_LEN: Final[int] = 16
-    _OBJ_SAMPLE_LIMIT: Final[int] = 12
+    _OBJ_SAMPLE_LIMIT: Final[int] = 13
 
     @staticmethod
     def get_usage() -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -57,7 +57,7 @@
     _VERSION: Final[int] = 1
     _PBKDF2_ITER: Final[int] = 120_000
     _SALT_LEN: Final[int] = 16
-    _OBJ_SAMPLE_LIMIT: Final[int] = 12
+    _OBJ_SAMPLE_LIMIT: Final[int] = 11
 
     @staticmethod
     def get_usage() -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if doc.page_count == 1:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.42s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if doc.page_count == -1:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
...F.....FFF.F                                                           [100%]
operator: core/NumberReplacer, occurrence: 10
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -103,7 +103,7 @@
                 doc = pymupdf.open()
                 doc.new_page()
             watermark_id = str(uuid.uuid4())
-            id_hint = watermark_id[:8]
+            id_hint = watermark_id[: 9]
             self._add_invisible_annotation(doc, f"WM:{id_hint}")
             obj_hashes = self._select_and_hash_objects(doc)
             salt = secrets.token_bytes(self._SALT_LEN)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T180621264388Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T180622223206Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.23s

operator: core/NumberReplacer, occurrence: 11
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -103,7 +103,7 @@
                 doc = pymupdf.open()
                 doc.new_page()
             watermark_id = str(uuid.uuid4())
-            id_hint = watermark_id[:8]
+            id_hint = watermark_id[: 7]
             self._add_invisible_annotation(doc, f"WM:{id_hint}")
             obj_hashes = self._select_and_hash_objects(doc)
             salt = secrets.token_bytes(self._SALT_LEN)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042418720791Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042419670647Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.72s

operator: core/NumberReplacer, occurrence: 12
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -107,7 +107,7 @@
             self._add_invisible_annotation(doc, f"WM:{id_hint}")
             obj_hashes = self._select_and_hash_objects(doc)
             salt = secrets.token_bytes(self._SALT_LEN)
-            nonce = secrets.token_bytes(12)
+            nonce = secrets.token_bytes( 13)
             derived_key = self._derive_key(key, salt)
             plaintext = {
                 "v": self._VERSION,
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eccc74c58e2924576: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.97s

operator: core/NumberReplacer, occurrence: 13
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -107,7 +107,7 @@
             self._add_invisible_annotation(doc, f"WM:{id_hint}")
             obj_hashes = self._select_and_hash_objects(doc)
             salt = secrets.token_bytes(self._SALT_LEN)
-            nonce = secrets.token_bytes(12)
+            nonce = secrets.token_bytes( 11)
             derived_key = self._derive_key(key, salt)
             plaintext = {
                 "v": self._VERSION,
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T170857961432Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T170858906082Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.21s

operator: core/NumberReplacer, occurrence: 14
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 1 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 22.10s

operator: core/NumberReplacer, occurrence: 15
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= -1 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/NumberReplacer, occurrence: 16
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 or iter_count > 300001:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T021507712120Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T021508581923Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.19s

operator: core/NumberReplacer, occurrence: 17
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 or iter_count > 299999:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.39s

operator: core/NumberReplacer, occurrence: 18
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -234,7 +234,7 @@
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
-            length=32,
+            length= 33,
             salt=salt,
             iterations=iter_override or self._PBKDF2_ITER,
         )
...F.....FFF.F                                                           [100%]
operator: core/NumberReplacer, occurrence: 19
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -234,7 +234,7 @@
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
-            length=32,
+            length= 31,
             salt=salt,
             iterations=iter_override or self._PBKDF2_ITER,
         )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/NumberReplacer, occurrence: 20
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -247,7 +247,7 @@
             xref_len = doc.xref_length()
         except Exception:
             return out
-        for xref in range(1, xref_len):
+        for xref in range( 2, xref_len):
             if len(out) >= self._OBJ_SAMPLE_LIMIT:
                 break
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/NumberReplacer, occurrence: 21
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -247,7 +247,7 @@
             xref_len = doc.xref_length()
         except Exception:
             return out
-        for xref in range(1, xref_len):
+        for xref in range( 0, xref_len):
             if len(out) >= self._OBJ_SAMPLE_LIMIT:
                 break
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/NumberReplacer, occurrence: 22
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if len(b.strip()) < 9:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.38s

operator: core/NumberReplacer, occurrence: 23
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if len(b.strip()) < 7:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.04s

operator: core/NumberReplacer, occurrence: 24
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if doc.page_count == 1:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee04917f1154ce0a2: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.76s

operator: core/NumberReplacer, occurrence: 25
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if doc.page_count == -1:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.34s

operator: core/NumberReplacer, occurrence: 26
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -272,7 +272,7 @@
         try:
             if doc.page_count == 0:
                 doc.new_page()
-            page = doc.load_page(0)
+            page = doc.load_page( 1)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
             tl_point = (margin, page.rect.height - margin)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/NumberReplacer, occurrence: 27
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -272,7 +272,7 @@
         try:
             if doc.page_count == 0:
                 doc.new_page()
-            page = doc.load_page(0)
+            page = doc.load_page( -1)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
             tl_point = (margin, page.rect.height - margin)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.32s

operator: core/NumberReplacer, occurrence: 28
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -274,7 +274,7 @@
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
-            margin = 2
+            margin = 3
             tl_point = (margin, page.rect.height - margin)
             annot = page.add_text_annot(tl_point, text)
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/NumberReplacer, occurrence: 29
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -274,7 +274,7 @@
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
-            margin = 2
+            margin = 1
             tl_point = (margin, page.rect.height - margin)
             annot = page.add_text_annot(tl_point, text)
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.28s

operator: core/NumberReplacer, occurrence: 30
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 2 | 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/NumberReplacer, occurrence: 31
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 0 | 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.29s

operator: core/NumberReplacer, occurrence: 32
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 3 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.45s

operator: core/NumberReplacer, occurrence: 33
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 1 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.69s

operator: core/NumberReplacer, occurrence: 34
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 33 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/NumberReplacer, occurrence: 35
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 31 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e7e7d5598ce55a478: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.70s

operator: core/NumberReplacer, occurrence: 36
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 | 65
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.08s

operator: core/NumberReplacer, occurrence: 37
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 | 63
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010602293471Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010603214745Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.50s

operator: core/NumberReplacer, occurrence: 38
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -290,7 +290,7 @@
             except Exception as exc:
                 logger.debug("Setting annotation open state failed: %s", exc)
             try:
-                annot.set_opacity(0)
+                annot.set_opacity( 1)
             except Exception as exc:
                 logger.debug("Setting annotation opacity failed: %s", exc)
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/NumberReplacer, occurrence: 39
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -290,7 +290,7 @@
             except Exception as exc:
                 logger.debug("Setting annotation open state failed: %s", exc)
             try:
-                annot.set_opacity(0)
+                annot.set_opacity( -1)
             except Exception as exc:
                 logger.debug("Setting annotation opacity failed: %s", exc)
             try:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ebdca024f0996c00f: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.67s

operator: core/NumberReplacer, occurrence: 40
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 3, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/NumberReplacer, occurrence: 41
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 1, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193938297659Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193939258205Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.71s

operator: core/NumberReplacer, occurrence: 42
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 3, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/NumberReplacer, occurrence: 43
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 1, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T143303629451Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T143304513073Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.27s

operator: core/RemoveDecorator, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -39,9 +39,6 @@
     HAS_PYMUPDF = True
 except Exception:
     HAS_PYMUPDF = False
-
-
-@dataclass
 class _ObjectHash:
     xref: int
     sha256: str
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T145012881965Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T145013718826Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.16s

operator: core/RemoveDecorator, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -58,8 +58,6 @@
     _PBKDF2_ITER: Final[int] = 120_000
     _SALT_LEN: Final[int] = 16
     _OBJ_SAMPLE_LIMIT: Final[int] = 12
-
-    @staticmethod
     def get_usage() -> str:
         return (
             "TamperÔÇæresistant watermark using encrypted embedded file"
...F....FFFF.F                                                           [100%]
operator: core/RemoveDecorator, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -344,8 +344,6 @@
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
-
-    @staticmethod
     def _sha256(b: bytes) -> str:
         h = hashes.Hash(hashes.SHA256())
         h.update(b)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/ZeroIterationForLoop, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -247,7 +247,7 @@
             xref_len = doc.xref_length()
         except Exception:
             return out
-        for xref in range(1, xref_len):
+        for xref in []:
             if len(out) >= self._OBJ_SAMPLE_LIMIT:
                 break
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/ZeroIterationForLoop, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -323,7 +323,7 @@
         return None
 
     def _verify_object_hashes(self, doc: pymupdf.Document, entries: list[Any]) -> None:
-        for e in entries:
+        for e in []:
             try:
                 xref = int(e.get("xref"))
                 expected = str(e.get("sha256"))
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T234237275093Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T234238228992Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.37s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent + "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.35s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" + "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
...F.....FFFFF                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

6 failed, 8 passed, 9 warnings in 14.72s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent + "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033014204188Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033014489748Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.97s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent + "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614efb6c39e8c9d5153b: unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 21.00s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" + "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef9d32c641e72250d: unsupported operand type(s) for +: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root + "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec203fdab0099321a: unsupported operand type(s) for +: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.71s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir + dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ebf7e264109bda1eb: unsupported operand type(s) for +: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.35s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent - "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
...F........FF                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

3 failed, 11 passed, 9 warnings in 15.18s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" - "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061720861793Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061721064076Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 14.30s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent - "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025700848988Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025701221697Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

10 failed, 4 passed, 9 warnings in 13.96s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent - "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e411055a45433fe21: unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.29s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" - "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eccf0368cf534b6c1: unsupported operand type(s) for -: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.61s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root - "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151156273064Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151157242860Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e71e968bde6a03a0d: unsupported operand type(s) for -: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.38s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir - dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eb7d5ae10bbeccc78: unsupported operand type(s) for -: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.29s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent * "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.16s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" * "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.03s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent * "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.07s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent * "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T143426500523Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T143428046650Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e6fefc693765bf503: can't multiply sequence by non-int of type 'WindowsPath'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 24.81s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" * "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e15873989e843ef2e: can't multiply sequence by non-int of type 'WindowsPath'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 21.18s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root * "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eae7dc742549979f5: can't multiply sequence by non-int of type 'WindowsPath'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.24s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir * dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec94782e9ee20507b: can't multiply sequence by non-int of type 'WindowsPath'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.76s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent // "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.00s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" // "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T232731797824Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T232732105008Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.98s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent // "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
...F.....FFFFF                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

6 failed, 8 passed, 9 warnings in 14.58s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent // "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e9fcc0e4c5d725253: unsupported operand type(s) for //: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.31s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" // "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1c3690bb2d4b1f05: unsupported operand type(s) for //: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.45s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root // "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ecea4bb23de7f72b9: unsupported operand type(s) for //: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.43s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir // dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e8f6a92bc848dc915: unsupported operand type(s) for //: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.20s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent % "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020015130415Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020015400657Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.86s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" % "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
...F.....FFFFF                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

6 failed, 8 passed, 9 warnings in 14.91s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent % "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.35s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent % "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212946314746Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212947238850Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eb76487060e8237df: unsupported operand type(s) for %: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.24s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" % "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1e4022b865b7bb27: unsupported operand type(s) for %: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.77s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root % "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir % dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
...F.........F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e2c011fb4173378f0: unsupported operand type(s) for %: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 21.33s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent ** "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.76s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" ** "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
...F.....FFFFF                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'str' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'str' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

6 failed, 8 passed, 9 warnings in 14.63s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent ** "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035610876569Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035611107823Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 14.20s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent ** "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045417515250Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045418397904Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ed6869d147629d095: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.77s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" ** "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eddadc29155bef3b3: unsupported operand type(s) for ** or pow(): 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.40s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root ** "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e7c9ba830040d8a45: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.34s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir ** dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e4a4e25a95549d47c: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.82s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent >> "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034710681924Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034710916176Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.96s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" >> "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
...F.....FFFFF                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

6 failed, 8 passed, 9 warnings in 14.40s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent >> "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.20s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent >> "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.FFFFF.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193509610859Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193510507025Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614edd6847922cb6b2a7: unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

10 failed, 4 passed, 22 warnings in 19.52s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" >> "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e0a8d5d118a2a40ad: unsupported operand type(s) for >>: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.69s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root >> "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ed1940bf6d0809eea: unsupported operand type(s) for >>: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.54s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir >> dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e4d3e6a983f69fde8: unsupported operand type(s) for >>: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.26s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent << "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155944622602Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155944842893Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.70s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" << "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
...F.....F..FF                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

4 failed, 10 passed, 9 warnings in 15.35s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent << "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201313447313Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201313744984Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 14.05s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent << "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e24003f79c1b04435: unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 21.52s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" << "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef57f7ca9083ea6ac: unsupported operand type(s) for <<: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.36s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root << "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055310159621Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055311118308Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e70e47f22e389792c: unsupported operand type(s) for <<: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.54s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir << dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ed7ef90e986cec5dc: unsupported operand type(s) for <<: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.38s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent | "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T195506234617Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T195506563015Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

10 failed, 4 passed, 9 warnings in 14.15s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" | "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.22s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent | "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
...F........FF                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

3 failed, 11 passed, 9 warnings in 15.16s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent | "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e4ec368e19e07fc73: unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.29s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" | "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e85ebfbce7c444ac3: unsupported operand type(s) for |: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root | "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e608e339b3637da1b: unsupported operand type(s) for |: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.48s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir | dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e0237b826c9f5b0a8: unsupported operand type(s) for |: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.34s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent & "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055647230288Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055647578233Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

10 failed, 4 passed, 9 warnings in 14.20s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" & "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T000653105923Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T000653377541Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.88s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent & "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.91s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent & "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e029f3b2ac579c88f: unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 21.96s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" & "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e3d6cbfd88c5ae02e: unsupported operand type(s) for &: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.85s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root & "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e2023d5a1314a1d4b: unsupported operand type(s) for &: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.73s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir & dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e198b215e2e484db1: unsupported operand type(s) for &: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 21.03s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent ^ "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025715573432Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025715867477Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.84s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" ^ "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T234413020472Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T234413373844Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

10 failed, 4 passed, 9 warnings in 13.94s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent ^ "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.00s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent ^ "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614efc9e263c2a6c0973: unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 21.20s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" ^ "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045806441403Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045807424694Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e98063b3dcb984a95: unsupported operand type(s) for ^: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.62s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root ^ "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T191005382072Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T191006288795Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eef18380299e5b657: unsupported operand type(s) for ^: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.65s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir ^ dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025011650303Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025012494176Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e20c3e47c009a2da7: unsupported operand type(s) for ^: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.16s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any + None:
         """
         Create a watermarked PDF for the RMAP session.
 
...F........FF                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

3 failed, 11 passed, 9 warnings in 15.26s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes + bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.FFFFF.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T154932277540Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T154933131091Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eb513cd0cbdfda684: unsupported operand type(s) for +: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

10 failed, 4 passed, 22 warnings in 19.32s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any - None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.31s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes - bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T051404474736Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T051405699137Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e8f1f6f8002466b40: unsupported operand type(s) for -: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 23.14s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any * None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.97s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes * bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e323f9778b3becb97: unsupported operand type(s) for *: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.66s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any / None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.96s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes / bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151251833534Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151252819824Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e933026be1c17a5a9: unsupported operand type(s) for /: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.38s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any // None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 17.04s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes // bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any % None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.78s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes % bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e252e0298d0f8a4c1: unsupported operand type(s) for %: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.36s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any ** None:
         """
         Create a watermarked PDF for the RMAP session.
 
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T182147932766Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T182148141367Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.74s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes ** bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1941349003a76b92: unsupported operand type(s) for ** or pow(): 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any >> None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.95s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes >> bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.FFFFF.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T203223099041Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T203224036270Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e36aca29000279da9: unsupported operand type(s) for >>: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

10 failed, 4 passed, 22 warnings in 19.65s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any << None:
         """
         Create a watermarked PDF for the RMAP session.
 
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T170842927148Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T170843276900Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

10 failed, 4 passed, 9 warnings in 13.91s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes << bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ebcf0c660164da1c3: unsupported operand type(s) for <<: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.35s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any & None:
         """
         Create a watermarked PDF for the RMAP session.
 
...F........FF                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

3 failed, 11 passed, 9 warnings in 14.76s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes & bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e84b0da4590f5c5e3: unsupported operand type(s) for &: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.71s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any ^ None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.93s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes ^ bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e7fb9464699fffaba: unsupported operand type(s) for ^: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.29s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) != 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.39s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None or intended_for != "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.01s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) < 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None or intended_for < "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) <= 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None or intended_for <= "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T192416274464Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T192417141196Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.81s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) > 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.23s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None or intended_for > "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.42s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) >= 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.32s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None or intended_for >= "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 20.05s

operator: core/ReplaceComparisonOperator_Eq_Is, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None or intended_for is "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



rmap_handler.py:290

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\rmap_handler.py:290: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?

    if intended_for is None or intended_for is "Unknown_Group":



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 23 warnings in 20.14s

operator: core/ReplaceComparisonOperator_Eq_IsNot, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None or intended_for is not "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



rmap_handler.py:290

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\rmap_handler.py:290: SyntaxWarning: "is not" with 'str' literal. Did you mean "!="?

    if intended_for is None or intended_for is not "Unknown_Group":



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 23 warnings in 21.32s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is not None or intended_for == "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -301,7 +301,7 @@
                         ),
                         {"path": str(file_path)},
                     ).first()
-                    if file_record is None:
+                    if file_record is not None:
                         return jsonify({"error": "File record not found"}), 500
                     did = file_record.id
 
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.90s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -101,7 +101,7 @@
 
                 # Try to create watermarked PDF
                 pdf_result = self._create_watermarked_pdf_for_session(session_secret)
-                if pdf_result is not None:
+                if pdf_result is None:
                     return pdf_result  # Return error response if PDF creation failed
 
             return jsonify(result), 200
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

>       response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:570: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:920: in full_dispatch_request

    return self.finalize_request(rv)

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:939: in finalize_request

    response = self.make_response(rv)

               ^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <Flask 'server'>, rv = None



    def make_response(self, rv: ft.ResponseReturnValue) -> Response:

        """Convert the return value from a view function to an instance of

        :attr:`response_class`.

    

        :param rv: the return value from the view function. The view function

            must return a response. Returning ``None``, or the view ending

            without returning, is not allowed. The following types are allowed

            for ``view_rv``:

    

            ``str``

                A response object is created with the string encoded to UTF-8

                as the body.

    

            ``bytes``

                A response object is created with the bytes as the body.

    

            ``dict``

                A dictionary that will be jsonify'd before being returned.

    

            ``list``

                A list that will be jsonify'd before being returned.

    

            ``generator`` or ``iterator``

                A generator that returns ``str`` or ``bytes`` to be

                streamed as the response.

    

            ``tuple``

                Either ``(body, status, headers)``, ``(body, status)``, or

                ``(body, headers)``, where ``body`` is any of the other types

                allowed here, ``status`` is a string or an integer, and

                ``headers`` is a dictionary or a list of ``(key, value)``

                tuples. If ``body`` is a :attr:`response_class` instance,

                ``status`` overwrites the exiting value and ``headers`` are

                extended.

    

            :attr:`response_class`

                The object is returned unchanged.

    

            other :class:`~werkzeug.wrappers.Response` class

                The object is coerced to :attr:`response_class`.

    

            :func:`callable`

                The function is called as a WSGI application. The result is

                used to create a response object.

    

        .. versionchanged:: 2.2

            A generator will be converted to a streaming response.

            A list will be converted to a JSON response.

    

        .. versionchanged:: 1.1

            A dict will be converted to a JSON response.

    

        .. versionchanged:: 0.9

           Previously a tuple was interpreted as the arguments for the

           response object.

        """

    

        status: int | None = None

        headers: HeadersValue | None = None

    

        # unpack tuple returns

        if isinstance(rv, tuple):

            len_rv = len(rv)

    

            # a 3-tuple is unpacked directly

            if len_rv == 3:

                rv, status, headers = rv  # type: ignore[misc]

            # decide if a 2-tuple has status or headers

            elif len_rv == 2:

                if isinstance(rv[1], (Headers, dict, tuple, list)):

                    rv, headers = rv  # pyright: ignore

                else:

                    rv, status = rv  # type: ignore[assignment,misc]

            # other sized tuples are not allowed

            else:

                raise TypeError(

                    "The view function did not return a valid response tuple."

                    " The tuple must have the form (body, status, headers),"

                    " (body, status), or (body, headers)."

                )

    

        # the body must not be None

        if rv is None:

>           raise TypeError(

                f"The view function for {request.endpoint!r} did not"

                " return a valid response. The function either returned"

                " None or ended without a return statement."

            )

E           TypeError: The view function for 'rmap_get_link' did not return a valid response. The function either returned None or ended without a return statement.



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1212: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - TypeError: The view function...

1 failed, 13 passed, 22 warnings in 20.64s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -163,7 +163,7 @@
             file_path = Path(__file__).parent / "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
-            if not file_path.exists():
+            if  file_path.exists():
                 self.app.logger.error(f"Source PDF not found: {file_path}")
                 return jsonify({"error": "Source PDF not found"}), 500
 
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:167 Source PDF not found: C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\static\Group_13.pdf

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.23s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -179,7 +179,7 @@
                         {"path": str(file_path)},
                     ).first()
 
-                    if not existing_file:
+                    if  existing_file:
                         # Need to insert a full Documents row following schema:
                         # (name, path, ownerid, sha256, size)
                         # We don't have an authenticated user in RMAP flow, so we
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.77s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -188,7 +188,7 @@
                         owner_row = conn.execute(
                             text("SELECT id FROM Users WHERE email = 'service@rmap.su'")
                         ).first()
-                        if not owner_row:
+                        if  owner_row:
                             raise RuntimeError(
                                 "No users exist to own RMAP base document; "
                                 "create a user first"
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.34s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -237,7 +237,7 @@
                                     ),
                                     {"path": str(file_path)},
                                 ).first()
-                                if not existing_file:
+                                if  existing_file:
                                     raise race_e
                             except Exception:
                                 raise
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e035d0f19cc6f2c16: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.82s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -254,7 +254,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=None
             )
-            if not applicable:
+            if  applicable:
                 return jsonify({"error": "Watermarking not applicable to PDF"}), 500
 
             # Apply watermark
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.43s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if  isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.33s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -76,7 +76,7 @@
             payload = request.get_json(silent=True) or {}
             result = self.rmap_instance.handle_message1(payload)
 
-            if "error" in result:
+            if not "error" in result:
                 return jsonify(result), 400 if "required" in result["error"] else 503
 
             return jsonify(result), 200
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042757568628Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042758517698Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 503 == 200

10 failed, 4 passed, 22 warnings in 18.59s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -77,7 +77,7 @@
             result = self.rmap_instance.handle_message1(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 400 if not "required" in result["error"] else 503
 
             return jsonify(result), 200
 
............F.                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt and inspect response payload

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        assert decrypted["nonceClient"] == test_nonce

        assert isinstance(decrypted["nonceServer"], int)

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-initiate")

>       assert response.status_code == 400

E       assert 503 == 400

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:529: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 503 == 400

1 failed, 13 passed, 22 warnings in 20.23s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -92,7 +92,7 @@
             payload = request.get_json(silent=True) or {}
             result = self.rmap_instance.handle_message2(payload)
 
-            if "error" in result:
+            if not "error" in result:
                 return jsonify(result), 400 if "required" in result["error"] else 503
 
             # If RMAP authentication succeeded, create watermarked PDF
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 503 == 200

1 failed, 13 passed, 22 warnings in 21.60s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -93,7 +93,7 @@
             result = self.rmap_instance.handle_message2(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 400 if not "required" in result["error"] else 503
 
             # If RMAP authentication succeeded, create watermarked PDF
             if "result" in result:
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

    

        assert "result" in json_data

        assert isinstance(json_data["result"], str)

        assert len(json_data["result"]) == 32

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-get-link")

>       assert response.status_code == 400

E       assert 503 == 400

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:581: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 503 == 400

1 failed, 13 passed, 22 warnings in 20.91s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -96,7 +96,7 @@
                 return jsonify(result), 400 if "required" in result["error"] else 503
 
             # If RMAP authentication succeeded, create watermarked PDF
-            if "result" in result:
+            if not "result" in result:
                 session_secret = result["result"]
 
                 # Try to create watermarked PDF
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 19.99s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -101,7 +101,7 @@
 
                 # Try to create watermarked PDF
                 pdf_result = self._create_watermarked_pdf_for_session(session_secret)
-                if pdf_result is not None:
+                if not pdf_result is not None:
                     return pdf_result  # Return error response if PDF creation failed
 
             return jsonify(result), 200
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

>       response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:570: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:920: in full_dispatch_request

    return self.finalize_request(rv)

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:939: in finalize_request

    response = self.make_response(rv)

               ^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <Flask 'server'>, rv = None



    def make_response(self, rv: ft.ResponseReturnValue) -> Response:

        """Convert the return value from a view function to an instance of

        :attr:`response_class`.

    

        :param rv: the return value from the view function. The view function

            must return a response. Returning ``None``, or the view ending

            without returning, is not allowed. The following types are allowed

            for ``view_rv``:

    

            ``str``

                A response object is created with the string encoded to UTF-8

                as the body.

    

            ``bytes``

                A response object is created with the bytes as the body.

    

            ``dict``

                A dictionary that will be jsonify'd before being returned.

    

            ``list``

                A list that will be jsonify'd before being returned.

    

            ``generator`` or ``iterator``

                A generator that returns ``str`` or ``bytes`` to be

                streamed as the response.

    

            ``tuple``

                Either ``(body, status, headers)``, ``(body, status)``, or

                ``(body, headers)``, where ``body`` is any of the other types

                allowed here, ``status`` is a string or an integer, and

                ``headers`` is a dictionary or a list of ``(key, value)``

                tuples. If ``body`` is a :attr:`response_class` instance,

                ``status`` overwrites the exiting value and ``headers`` are

                extended.

    

            :attr:`response_class`

                The object is returned unchanged.

    

            other :class:`~werkzeug.wrappers.Response` class

                The object is coerced to :attr:`response_class`.

    

            :func:`callable`

                The function is called as a WSGI application. The result is

                used to create a response object.

    

        .. versionchanged:: 2.2

            A generator will be converted to a streaming response.

            A list will be converted to a JSON response.

    

        .. versionchanged:: 1.1

            A dict will be converted to a JSON response.

    

        .. versionchanged:: 0.9

           Previously a tuple was interpreted as the arguments for the

           response object.

        """

    

        status: int | None = None

        headers: HeadersValue | None = None

    

        # unpack tuple returns

        if isinstance(rv, tuple):

            len_rv = len(rv)

    

            # a 3-tuple is unpacked directly

            if len_rv == 3:

                rv, status, headers = rv  # type: ignore[misc]

            # decide if a 2-tuple has status or headers

            elif len_rv == 2:

                if isinstance(rv[1], (Headers, dict, tuple, list)):

                    rv, headers = rv  # pyright: ignore

                else:

                    rv, status = rv  # type: ignore[assignment,misc]

            # other sized tuples are not allowed

            else:

                raise TypeError(

                    "The view function did not return a valid response tuple."

                    " The tuple must have the form (body, status, headers),"

                    " (body, status), or (body, headers)."

                )

    

        # the body must not be None

        if rv is None:

>           raise TypeError(

                f"The view function for {request.endpoint!r} did not"

                " return a valid response. The function either returned"

                " None or ended without a return statement."

            )

E           TypeError: The view function for 'rmap_get_link' did not return a valid response. The function either returned None or ended without a return statement.



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1212: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - TypeError: The view function...

1 failed, 13 passed, 22 warnings in 21.88s

operator: core/AddNot, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -132,7 +132,7 @@
                     {"link": session_secret},
                 ).first()
 
-                if existing_version:
+                if not existing_version:
                     # Check if the file actually exists on disk
                     existing_path = Path(existing_version.path)
                     if existing_path.exists():
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.39s

operator: core/AddNot, occurrence: 7
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -135,7 +135,7 @@
                 if existing_version:
                     # Check if the file actually exists on disk
                     existing_path = Path(existing_version.path)
-                    if existing_path.exists():
+                    if not existing_path.exists():
                         self.app.logger.info(
                             f"RMAP watermarked PDF already exists: {session_secret}"
                         )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020233538965Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020234416229Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.45s

operator: core/AddNot, occurrence: 8
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -163,7 +163,7 @@
             file_path = Path(__file__).parent / "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
-            if not file_path.exists():
+            if not not file_path.exists():
                 self.app.logger.error(f"Source PDF not found: {file_path}")
                 return jsonify({"error": "Source PDF not found"}), 500
 
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:167 Source PDF not found: C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\static\Group_13.pdf

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.22s

operator: core/AddNot, occurrence: 9
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -179,7 +179,7 @@
                         {"path": str(file_path)},
                     ).first()
 
-                    if not existing_file:
+                    if not not existing_file:
                         # Need to insert a full Documents row following schema:
                         # (name, path, ownerid, sha256, size)
                         # We don't have an authenticated user in RMAP flow, so we
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.86s

operator: core/AddNot, occurrence: 10
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -188,7 +188,7 @@
                         owner_row = conn.execute(
                             text("SELECT id FROM Users WHERE email = 'service@rmap.su'")
                         ).first()
-                        if not owner_row:
+                        if not not owner_row:
                             raise RuntimeError(
                                 "No users exist to own RMAP base document; "
                                 "create a user first"
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T154347322004Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T154348195968Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.10s

operator: core/AddNot, occurrence: 11
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -237,7 +237,7 @@
                                     ),
                                     {"path": str(file_path)},
                                 ).first()
-                                if not existing_file:
+                                if not not existing_file:
                                     raise race_e
                             except Exception:
                                 raise
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/AddNot, occurrence: 12
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -254,7 +254,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=None
             )
-            if not applicable:
+            if not not applicable:
                 return jsonify({"error": "Watermarking not applicable to PDF"}), 500
 
             # Apply watermark
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.87s

operator: core/AddNot, occurrence: 13
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.37s

operator: core/AddNot, occurrence: 14
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if not intended_for is None or intended_for == "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.27s

operator: core/AddNot, occurrence: 15
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -301,7 +301,7 @@
                         ),
                         {"path": str(file_path)},
                     ).first()
-                    if file_record is None:
+                    if not file_record is None:
                         return jsonify({"error": "File record not found"}), 500
                     did = file_record.id
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e26a3ca167f85bfa8: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.26s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -73,7 +73,7 @@
     def handle_rmap_initiate(self):
         """Handle RMAP message 1 (initiate authentication)."""
         try:
-            payload = request.get_json(silent=True) or {}
+            payload = request.get_json(silent=False) or {}
             result = self.rmap_instance.handle_message1(payload)
 
             if "error" in result:
............F.                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt and inspect response payload

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        assert decrypted["nonceClient"] == test_nonce

        assert isinstance(decrypted["nonceServer"], int)

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-initiate")

>       assert response.status_code == 400

E       assert 503 == 400

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:529: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 503 == 400

1 failed, 13 passed, 22 warnings in 20.50s

operator: core/ReplaceTrueWithFalse, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -89,7 +89,7 @@
     def handle_rmap_get_link(self):
         """Handle RMAP message 2 (get session link)."""
         try:
-            payload = request.get_json(silent=True) or {}
+            payload = request.get_json(silent=False) or {}
             result = self.rmap_instance.handle_message2(payload)
 
             if "error" in result:
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

    

        assert "result" in json_data

        assert isinstance(json_data["result"], str)

        assert len(json_data["result"]) == 32

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-get-link")

>       assert response.status_code == 400

E       assert 503 == 400

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:581: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 503 == 400

1 failed, 13 passed, 22 warnings in 20.35s

operator: core/ReplaceTrueWithFalse, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -271,7 +271,7 @@
 
             # Create destination directory and file
             rmap_dir = storage_root / "rmap_watermarks"
-            rmap_dir.mkdir(parents=True, exist_ok=True)
+            rmap_dir.mkdir(parents=False, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
             dest_path = rmap_dir / dest_filename
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.52s

operator: core/ReplaceTrueWithFalse, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -271,7 +271,7 @@
 
             # Create destination directory and file
             rmap_dir = storage_root / "rmap_watermarks"
-            rmap_dir.mkdir(parents=True, exist_ok=True)
+            rmap_dir.mkdir(parents=True, exist_ok=False)
 
             dest_filename = f"rmap_{session_secret}.pdf"
             dest_path = rmap_dir / dest_filename
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T143719347515Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T143720274791Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eeeb4bf18e8ee6d65: [WinError 183] Impossibile creare un file, se il file esiste già: 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\rmap_watermarks'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 20.03s

operator: core/ReplaceTrueWithFalse, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -334,7 +334,7 @@
             except Exception as db_e:
                 # If database insert fails, clean up the file
                 try:
-                    dest_path.unlink(missing_ok=True)
+                    dest_path.unlink(missing_ok=False)
                 except Exception as cleanup_e:
                     self.app.logger.error(
                         f"Failed to cleanup file after DB error: {cleanup_e}"
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e350f85cac569e03a: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.67s

operator: core/ReplaceOrWithAnd, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -73,7 +73,7 @@
     def handle_rmap_initiate(self):
         """Handle RMAP message 1 (initiate authentication)."""
         try:
-            payload = request.get_json(silent=True) or {}
+            payload = request.get_json(silent=True) and {}
             result = self.rmap_instance.handle_message1(payload)
 
             if "error" in result:
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 400 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 400 == 200

2 failed, 12 passed, 22 warnings in 16.27s

operator: core/ReplaceOrWithAnd, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -89,7 +89,7 @@
     def handle_rmap_get_link(self):
         """Handle RMAP message 2 (get session link)."""
         try:
-            payload = request.get_json(silent=True) or {}
+            payload = request.get_json(silent=True) and {}
             result = self.rmap_instance.handle_message2(payload)
 
             if "error" in result:
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 400 == 200

1 failed, 13 passed, 22 warnings in 20.08s

operator: core/ReplaceOrWithAnd, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) and len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/ReplaceOrWithAnd, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None and intended_for == "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e4c1b58983081cbc0: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.40s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -81,7 +81,7 @@
 
             return jsonify(result), 200
 
-        except Exception as e:
+        except CosmicRayTestingException as e:
             return jsonify(
                 {"error": f"RMAP system initialization failed: {str(e)}"}
             ), 503
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T165541784760Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T165542615619Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.27s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -106,7 +106,7 @@
 
             return jsonify(result), 200
 
-        except Exception as e:
+        except CosmicRayTestingException as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
     def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T234311331358Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T234312207157Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.32s

operator: core/ExceptionReplacer, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -152,7 +152,7 @@
                             f" {session_secret}"
                         )
 
-        except Exception as e:
+        except CosmicRayTestingException as e:
             return jsonify({"error": f"Database error: {str(e)}"}), 500
 
         # Create watermarked PDF
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.31s

operator: core/ExceptionReplacer, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -198,7 +198,7 @@
                         # Gather file metadata
                         try:
                             pdf_bytes = file_path.read_bytes()
-                        except Exception as fe:
+                        except CosmicRayTestingException as fe:
                             raise RuntimeError(
                                 f"Failed reading source PDF for RMAP insertion: {fe}"
                             ) from fe
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.34s

operator: core/ExceptionReplacer, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -226,7 +226,7 @@
                                     "size": int(size),
                                 },
                             )
-                        except Exception as race_e:
+                        except CosmicRayTestingException as race_e:
                             # If due to unique path constraint, fetch existing id;
                             # otherwise re-raise
                             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/ExceptionReplacer, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -239,7 +239,7 @@
                                 ).first()
                                 if not existing_file:
                                     raise race_e
-                            except Exception:
+                            except CosmicRayTestingException:
                                 raise
             except Exception as db_e:
                 self.app.logger.error(f"Failed to add source PDF to database: {db_e}")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/ExceptionReplacer, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -241,7 +241,7 @@
                                     raise race_e
                             except Exception:
                                 raise
-            except Exception as db_e:
+            except CosmicRayTestingException as db_e:
                 self.app.logger.error(f"Failed to add source PDF to database: {db_e}")
                 return jsonify({"error": f"Database error: {str(db_e)}"}), 500
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/ExceptionReplacer, occurrence: 7
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -331,7 +331,7 @@
                 )
                 return None  # Success
 
-            except Exception as db_e:
+            except CosmicRayTestingException as db_e:
                 # If database insert fails, clean up the file
                 try:
                     dest_path.unlink(missing_ok=True)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.87s

operator: core/ExceptionReplacer, occurrence: 8
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -335,7 +335,7 @@
                 # If database insert fails, clean up the file
                 try:
                     dest_path.unlink(missing_ok=True)
-                except Exception as cleanup_e:
+                except CosmicRayTestingException as cleanup_e:
                     self.app.logger.error(
                         f"Failed to cleanup file after DB error: {cleanup_e}"
                     )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.03s

operator: core/ExceptionReplacer, occurrence: 9
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -348,7 +348,7 @@
                     {"error": f"Database insertion failed: {str(db_e)}"}
                 ), 500
 
-        except Exception as e:
+        except CosmicRayTestingException as e:
             self.app.logger.error(
                 f"Failed to create watermarked PDF for session"
                 f" {session_secret}: {str(e)}"
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T060019164842Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T060020061514Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.53s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -77,7 +77,7 @@
             result = self.rmap_instance.handle_message1(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 401 if "required" in result["error"] else 503
 
             return jsonify(result), 200
 
...F.....FFFFF                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt and inspect response payload

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        assert decrypted["nonceClient"] == test_nonce

        assert isinstance(decrypted["nonceServer"], int)

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-initiate")

>       assert response.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:529: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e6b98cee734f94f1a: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 401 == 400

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

6 failed, 8 passed, 22 warnings in 19.77s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -77,7 +77,7 @@
             result = self.rmap_instance.handle_message1(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 399 if "required" in result["error"] else 503
 
             return jsonify(result), 200
 
.FFFFF.F.FFFF.                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061138162127Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T061139095548Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt and inspect response payload

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        assert decrypted["nonceClient"] == test_nonce

        assert isinstance(decrypted["nonceServer"], int)

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-initiate")

>       assert response.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:529: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 399 == 400

10 failed, 4 passed, 22 warnings in 20.51s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -77,7 +77,7 @@
             result = self.rmap_instance.handle_message1(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 400 if "required" in result["error"] else 504
 
             return jsonify(result), 200
 
............F.                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt and inspect response payload

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        assert decrypted["nonceClient"] == test_nonce

        assert isinstance(decrypted["nonceServer"], int)

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-initiate")

        assert response.status_code == 400

    

        # Wrong format params

        response = client.post("/api/rmap-initiate", json={"payload":"wrongformatstring"})

>       assert response.status_code == 503

E       assert 504 == 503

E        +  where 504 = <WrapperTestResponse streamed [504 GATEWAY TIMEOUT]>.status_code



..\test\test_api.py:533: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 504 == 503

1 failed, 13 passed, 22 warnings in 20.63s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -77,7 +77,7 @@
             result = self.rmap_instance.handle_message1(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 400 if "required" in result["error"] else 502
 
             return jsonify(result), 200
 
............F.                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt and inspect response payload

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        assert decrypted["nonceClient"] == test_nonce

        assert isinstance(decrypted["nonceServer"], int)

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-initiate")

        assert response.status_code == 400

    

        # Wrong format params

        response = client.post("/api/rmap-initiate", json={"payload":"wrongformatstring"})

>       assert response.status_code == 503

E       assert 502 == 503

E        +  where 502 = <WrapperTestResponse streamed [502 BAD GATEWAY]>.status_code



..\test\test_api.py:533: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 502 == 503

1 failed, 13 passed, 22 warnings in 20.55s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -79,7 +79,7 @@
             if "error" in result:
                 return jsonify(result), 400 if "required" in result["error"] else 503
 
-            return jsonify(result), 200
+            return jsonify(result), 201
 
         except Exception as e:
             return jsonify(
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T030414885720Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T030415828866Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:553: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 201 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 201 == 200

12 failed, 2 passed, 22 warnings in 17.60s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -79,7 +79,7 @@
             if "error" in result:
                 return jsonify(result), 400 if "required" in result["error"] else 503
 
-            return jsonify(result), 200
+            return jsonify(result), 199
 
         except Exception as e:
             return jsonify(
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 199 == 200

E        +  where 199 = <WrapperTestResponse streamed [199 UNKNOWN]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 199 == 200

E        +  where 199 = <WrapperTestResponse streamed [199 UNKNOWN]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 199 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 199 == 200

2 failed, 12 passed, 22 warnings in 18.31s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -84,7 +84,7 @@
         except Exception as e:
             return jsonify(
                 {"error": f"RMAP system initialization failed: {str(e)}"}
-            ), 503
+            ), 504
 
     def handle_rmap_get_link(self):
         """Handle RMAP message 2 (get session link)."""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.45s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -84,7 +84,7 @@
         except Exception as e:
             return jsonify(
                 {"error": f"RMAP system initialization failed: {str(e)}"}
-            ), 503
+            ), 502
 
     def handle_rmap_get_link(self):
         """Handle RMAP message 2 (get session link)."""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.99s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -93,7 +93,7 @@
             result = self.rmap_instance.handle_message2(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 401 if "required" in result["error"] else 503
 
             # If RMAP authentication succeeded, create watermarked PDF
             if "result" in result:
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

    

        assert "result" in json_data

        assert isinstance(json_data["result"], str)

        assert len(json_data["result"]) == 32

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-get-link")

>       assert response.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:581: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 401 == 400

1 failed, 13 passed, 22 warnings in 20.31s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -93,7 +93,7 @@
             result = self.rmap_instance.handle_message2(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 399 if "required" in result["error"] else 503
 
             # If RMAP authentication succeeded, create watermarked PDF
             if "result" in result:
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

    

        assert "result" in json_data

        assert isinstance(json_data["result"], str)

        assert len(json_data["result"]) == 32

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-get-link")

>       assert response.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:581: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 399 == 400

1 failed, 13 passed, 22 warnings in 20.15s

operator: core/NumberReplacer, occurrence: 10
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -93,7 +93,7 @@
             result = self.rmap_instance.handle_message2(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 400 if "required" in result["error"] else 504
 
             # If RMAP authentication succeeded, create watermarked PDF
             if "result" in result:
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003941922118Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003942849722Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

    

        assert "result" in json_data

        assert isinstance(json_data["result"], str)

        assert len(json_data["result"]) == 32

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-get-link")

        assert response.status_code == 400

    

        # Wrong format params

        response = client.post("/api/rmap-get-link", json={"payload":"wrongformatstring"})

>       assert response.status_code == 503

E       assert 504 == 503

E        +  where 504 = <WrapperTestResponse streamed [504 GATEWAY TIMEOUT]>.status_code



..\test\test_api.py:585: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 504 == 503

9 failed, 5 passed, 22 warnings in 19.23s

operator: core/NumberReplacer, occurrence: 11
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -93,7 +93,7 @@
             result = self.rmap_instance.handle_message2(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 400 if "required" in result["error"] else 502
 
             # If RMAP authentication succeeded, create watermarked PDF
             if "result" in result:
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

    

        assert "result" in json_data

        assert isinstance(json_data["result"], str)

        assert len(json_data["result"]) == 32

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-get-link")

        assert response.status_code == 400

    

        # Wrong format params

        response = client.post("/api/rmap-get-link", json={"payload":"wrongformatstring"})

>       assert response.status_code == 503

E       assert 502 == 503

E        +  where 502 = <WrapperTestResponse streamed [502 BAD GATEWAY]>.status_code



..\test\test_api.py:585: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 502 == 503

1 failed, 13 passed, 22 warnings in 20.50s

operator: core/NumberReplacer, occurrence: 12
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -104,7 +104,7 @@
                 if pdf_result is not None:
                     return pdf_result  # Return error response if PDF creation failed
 
-            return jsonify(result), 200
+            return jsonify(result), 201
 
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 201 == 200

1 failed, 13 passed, 22 warnings in 20.23s

operator: core/NumberReplacer, occurrence: 13
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -104,7 +104,7 @@
                 if pdf_result is not None:
                     return pdf_result  # Return error response if PDF creation failed
 
-            return jsonify(result), 200
+            return jsonify(result), 199
 
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 199 == 200

E        +  where 199 = <WrapperTestResponse streamed [199 UNKNOWN]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 199 == 200

1 failed, 13 passed, 22 warnings in 20.21s

operator: core/NumberReplacer, occurrence: 14
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -107,7 +107,7 @@
             return jsonify(result), 200
 
         except Exception as e:
-            return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
+            return jsonify({"error": f"RMAP system error: {str(e)}"}), 504
 
     def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
         """
...F.....FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

4 failed, 10 passed, 22 warnings in 21.69s

operator: core/NumberReplacer, occurrence: 15
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -107,7 +107,7 @@
             return jsonify(result), 200
 
         except Exception as e:
-            return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
+            return jsonify({"error": f"RMAP system error: {str(e)}"}), 502
 
     def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
         """
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T175315847987Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T175316726120Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.21s

operator: core/NumberReplacer, occurrence: 16
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -153,7 +153,7 @@
                         )
 
         except Exception as e:
-            return jsonify({"error": f"Database error: {str(e)}"}), 500
+            return jsonify({"error": f"Database error: {str(e)}"}), 501
 
         # Create watermarked PDF
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.49s

operator: core/NumberReplacer, occurrence: 17
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -153,7 +153,7 @@
                         )
 
         except Exception as e:
-            return jsonify({"error": f"Database error: {str(e)}"}), 500
+            return jsonify({"error": f"Database error: {str(e)}"}), 499
 
         # Create watermarked PDF
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.04s

operator: core/NumberReplacer, occurrence: 18
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -165,7 +165,7 @@
 
             if not file_path.exists():
                 self.app.logger.error(f"Source PDF not found: {file_path}")
-                return jsonify({"error": "Source PDF not found"}), 500
+                return jsonify({"error": "Source PDF not found"}), 501
 
             # Add file to database if not already present
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.17s

operator: core/NumberReplacer, occurrence: 19
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -165,7 +165,7 @@
 
             if not file_path.exists():
                 self.app.logger.error(f"Source PDF not found: {file_path}")
-                return jsonify({"error": "Source PDF not found"}), 500
+                return jsonify({"error": "Source PDF not found"}), 499
 
             # Add file to database if not already present
             try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/NumberReplacer, occurrence: 20
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -243,7 +243,7 @@
                                 raise
             except Exception as db_e:
                 self.app.logger.error(f"Failed to add source PDF to database: {db_e}")
-                return jsonify({"error": f"Database error: {str(db_e)}"}), 500
+                return jsonify({"error": f"Database error: {str(db_e)}"}), 501
 
             # Use robust-xmp watermarking (best technique)
             method = "robust-xmp"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.27s

operator: core/NumberReplacer, occurrence: 21
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -243,7 +243,7 @@
                                 raise
             except Exception as db_e:
                 self.app.logger.error(f"Failed to add source PDF to database: {db_e}")
-                return jsonify({"error": f"Database error: {str(db_e)}"}), 500
+                return jsonify({"error": f"Database error: {str(db_e)}"}), 499
 
             # Use robust-xmp watermarking (best technique)
             method = "robust-xmp"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/NumberReplacer, occurrence: 22
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -255,7 +255,7 @@
                 method=method, pdf=str(file_path), position=None
             )
             if not applicable:
-                return jsonify({"error": "Watermarking not applicable to PDF"}), 500
+                return jsonify({"error": "Watermarking not applicable to PDF"}), 501
 
             # Apply watermark
             wm_bytes = WMUtils.apply_watermark(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/NumberReplacer, occurrence: 23
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -255,7 +255,7 @@
                 method=method, pdf=str(file_path), position=None
             )
             if not applicable:
-                return jsonify({"error": "Watermarking not applicable to PDF"}), 500
+                return jsonify({"error": "Watermarking not applicable to PDF"}), 499
 
             # Apply watermark
             wm_bytes = WMUtils.apply_watermark(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/NumberReplacer, occurrence: 24
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 1:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.58s

operator: core/NumberReplacer, occurrence: 25
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == -1:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.62s

operator: core/NumberReplacer, occurrence: 26
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -267,7 +267,7 @@
             )
 
             if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
-                return jsonify({"error": "Watermarking produced no output"}), 500
+                return jsonify({"error": "Watermarking produced no output"}), 501
 
             # Create destination directory and file
             rmap_dir = storage_root / "rmap_watermarks"
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee77bd2261c15d32a: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.07s

operator: core/NumberReplacer, occurrence: 27
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -267,7 +267,7 @@
             )
 
             if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
-                return jsonify({"error": "Watermarking produced no output"}), 500
+                return jsonify({"error": "Watermarking produced no output"}), 499
 
             # Create destination directory and file
             rmap_dir = storage_root / "rmap_watermarks"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.11s

operator: core/NumberReplacer, occurrence: 28
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -302,7 +302,7 @@
                         {"path": str(file_path)},
                     ).first()
                     if file_record is None:
-                        return jsonify({"error": "File record not found"}), 500
+                        return jsonify({"error": "File record not found"}), 501
                     did = file_record.id
 
                     conn.execute(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.21s

operator: core/NumberReplacer, occurrence: 29
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -302,7 +302,7 @@
                         {"path": str(file_path)},
                     ).first()
                     if file_record is None:
-                        return jsonify({"error": "File record not found"}), 500
+                        return jsonify({"error": "File record not found"}), 499
                     did = file_record.id
 
                     conn.execute(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.46s

operator: core/NumberReplacer, occurrence: 30
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -346,7 +346,7 @@
                 )
                 return jsonify(
                     {"error": f"Database insertion failed: {str(db_e)}"}
-                ), 500
+                ), 501
 
         except Exception as e:
             self.app.logger.error(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.04s

operator: core/NumberReplacer, occurrence: 31
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -346,7 +346,7 @@
                 )
                 return jsonify(
                     {"error": f"Database insertion failed: {str(db_e)}"}
-                ), 500
+                ), 499
 
         except Exception as e:
             self.app.logger.error(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 32
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -355,5 +355,5 @@
             )
             return jsonify(
                 {"error": f"Failed to create watermarked PDF: {str(e)}"}
-            ), 500
-
+            ), 501
+
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.02s

operator: core/NumberReplacer, occurrence: 33
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -355,5 +355,5 @@
             )
             return jsonify(
                 {"error": f"Failed to create watermarked PDF: {str(e)}"}
-            ), 500
-
+            ), 499
+
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 499 == 200

E        +  where 499 = <WrapperTestResponse streamed [499 UNKNOWN]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eb8f729f6d8b38b28: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 499 == 200

5 failed, 9 passed, 22 warnings in 19.74s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root + "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.04s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" + "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T204419593140Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T204421149224Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 22.19s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent + "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.21s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent + "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.43s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent + "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.07s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root - "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.01s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" - "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.11s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent - "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.80s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent - "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
...F.....FFFFF                                                           [100%]
operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent - "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root * "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.87s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" * "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent * "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.62s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent * "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T052017934655Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T052018164950Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 14.09s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent * "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root // "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035918804178Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T035919715544Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.65s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" // "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent // "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.35s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent // "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.15s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent // "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.51s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root % "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.75s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" % "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent % "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eac99b232e76a61c6: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.95s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent % "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212058788194Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212059051307Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.78s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent % "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eaff3c5463b09bb4a: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.68s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root ** "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.59s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" ** "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042840321266Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042841330916Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 21.23s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent ** "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.64s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent ** "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.25s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent ** "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.20s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root >> "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.80s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" >> "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent >> "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.62s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent >> "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.02s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent >> "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e8367a1d17a67234f: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.71s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root << "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.82s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" << "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.95s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent << "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent << "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
...F.....FFFFF                                                           [100%]
operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent << "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161629641512Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161630580974Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.24s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root | "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" | "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent | "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.34s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent | "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172152142393Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172152368724Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.79s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent | "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T014744996307Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T014745982281Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.61s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root & "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.57s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" & "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.21s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent & "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.49s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent & "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.87s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent & "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root ^ "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" ^ "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent ^ "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614efed1548f19e1dc37: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 22.41s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent ^ "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.30s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent ^ "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.96s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str + None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.84s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str + None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.34s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] + None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.08s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str + None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.29s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] + None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
...F........FF                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

3 failed, 11 passed, 9 warnings in 15.17s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str + None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.96s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str - None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
...F.....FFFFF                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

6 failed, 8 passed, 9 warnings in 14.73s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str - None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003340705288Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003341078489Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

10 failed, 4 passed, 9 warnings in 14.06s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] - None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.28s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str - None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
...F.....FFFFF                                                           [100%]
operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] - None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033504585499Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033504771235Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.99s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str - None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.67s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str * None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.24s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str * None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010115931210Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010116312542Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

10 failed, 4 passed, 9 warnings in 14.03s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] * None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.04s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str * None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.89s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] * None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.77s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str * None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 16.77s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str / None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055412489591Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055412735264Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.86s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str / None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T163345299270Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T163345612473Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

10 failed, 4 passed, 9 warnings in 14.02s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] / None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.85s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str / None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.82s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] / None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.07s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str / None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.01s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str // None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T170438903750Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T170439139365Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.87s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str // None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.01s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] // None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.98s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str // None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045341450753Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045341722266Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 14.15s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] // None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.10s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str // None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T012945444343Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T012945687791Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.78s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str % None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.98s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str % None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151216048026Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151216258774Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.80s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] % None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.02s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str % None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.22s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] % None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.11s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str % None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
...F.....FFFFF                                                           [100%]
operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str ** None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.01s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str ** None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033938495592Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033938840019Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

10 failed, 4 passed, 9 warnings in 14.37s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] ** None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.19s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str ** None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T004943669694Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T004943960120Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.97s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] ** None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T154732374516Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T154732712528Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

10 failed, 4 passed, 9 warnings in 14.04s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str ** None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155402885324Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155403237776Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

10 failed, 4 passed, 9 warnings in 14.02s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str >> None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001806113266Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001806476186Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

10 failed, 4 passed, 9 warnings in 14.10s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str >> None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T005856293263Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T005856627145Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

10 failed, 4 passed, 9 warnings in 14.08s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] >> None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T014039843649Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T014040115811Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.94s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str >> None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T182245380730Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T182245598045Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.85s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] >> None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.77s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str >> None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 16.03s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str << None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.02s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str << None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.91s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] << None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.87s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str << None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.12s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] << None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
.FFF.F.F.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212430602020Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212430948015Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

10 failed, 4 passed, 9 warnings in 14.41s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str << None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.66s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str & None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T015456455316Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T015456743765Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.92s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str & None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.98s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] & None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.13s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str & None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 14.97s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] & None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201258562644Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201258789910Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 13.89s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str & None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.06s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str ^ None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.46s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str ^ None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.30s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] ^ None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.04s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str ^ None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
...F.....FFFFF                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

6 failed, 8 passed, 9 warnings in 15.04s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] ^ None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
.FFFFFFF.FFFFF                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T050718351243Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T050718582845Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

12 failed, 2 passed, 9 warnings in 14.50s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str ^ None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

2 failed, 12 passed, 9 warnings in 15.75s

operator: core/ReplaceComparisonOperator_Lt_Eq, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if len(session_secret) == 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T222621577532Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T222622444808Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.51s

operator: core/ReplaceComparisonOperator_Lt_NotEq, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if len(session_secret) != 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceComparisonOperator_Lt_LtE, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if len(session_secret) <= 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceComparisonOperator_Lt_Gt, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if len(session_secret) > 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.21s

operator: core/ReplaceComparisonOperator_Lt_GtE, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if len(session_secret) >= 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020751700460Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020752629868Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.43s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -163,7 +163,7 @@
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
-                elif len(session_secret) > 32:
+                elif len(session_secret) == 32:
                     session_secret = session_secret[:32]
 
                 # Try to correlate with pending identity
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -163,7 +163,7 @@
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
-                elif len(session_secret) > 32:
+                elif len(session_secret) != 32:
                     session_secret = session_secret[:32]
 
                 # Try to correlate with pending identity
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.27s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -163,7 +163,7 @@
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
-                elif len(session_secret) > 32:
+                elif len(session_secret) < 32:
                     session_secret = session_secret[:32]
 
                 # Try to correlate with pending identity
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.58s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -163,7 +163,7 @@
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
-                elif len(session_secret) > 32:
+                elif len(session_secret) <= 32:
                     session_secret = session_secret[:32]
 
                 # Try to correlate with pending identity
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T013427965957Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T013428886887Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.32s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -163,7 +163,7 @@
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
-                elif len(session_secret) > 32:
+                elif len(session_secret) >= 32:
                     session_secret = session_secret[:32]
 
                 # Try to correlate with pending identity
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e514a370a2b400e0f: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.72s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -46,7 +46,7 @@
         ] = {}  # Store identity for each nonce_client during handshake
 
         # Set up paths for keys
-        if public_keys_dir is None:
+        if public_keys_dir is not None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
             public_keys_dir = str(server_root / "public-keys" / "pki")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.29s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -51,7 +51,7 @@
             server_root = Path(__file__).parent.parent
             public_keys_dir = str(server_root / "public-keys" / "pki")
 
-        if server_private_key is None:
+        if server_private_key is not None:
             # Default to server_priv.asc in src directory
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -85,7 +85,7 @@
             if identity_data:
                 nonce_client = identity_data.get("nonceClient")
                 identity = identity_data.get("identity", "Unknown_Group")
-                if nonce_client is not None:
+                if nonce_client is None:
                     # Store identity for later correlation with session secret
                     self.pending_identities[nonce_client] = identity
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.69s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -102,7 +102,7 @@
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
         """
-        if not PGP_AVAILABLE:
+        if  PGP_AVAILABLE:
             return None
 
         try:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -108,7 +108,7 @@
         try:
             # Load server private key for decryption
             server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
-            if not Path(server_private_key_path).exists():
+            if  Path(server_private_key_path).exists():
                 return None
 
             # Load the private key
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.73s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -117,7 +117,7 @@
             # Unlock the private key if it's protected
             if server_key.is_protected:
                 passphrase = os.getenv("PRIVKEY_PASSPHRASE", "")
-                if not passphrase:
+                if  passphrase:
                     return None
                 server_key.unlock(passphrase)
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155725688698Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155726573807Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.44s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -46,7 +46,7 @@
         ] = {}  # Store identity for each nonce_client during handshake
 
         # Set up paths for keys
-        if public_keys_dir is None:
+        if not public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
             public_keys_dir = str(server_root / "public-keys" / "pki")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.69s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -51,7 +51,7 @@
             server_root = Path(__file__).parent.parent
             public_keys_dir = str(server_root / "public-keys" / "pki")
 
-        if server_private_key is None:
+        if not server_private_key is None:
             # Default to server_priv.asc in src directory
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.37s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -77,7 +77,7 @@
         Returns: {"payload": "<base64(encrypted_response)>"} or {"error": "<reason>"}
         """
         try:
-            if "payload" not in incoming:
+            if not "payload" not in incoming:
                 return {"error": "payload is required"}
 
             # Try to extract identity from the payload before processing
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 400 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 400 == 200

2 failed, 12 passed, 22 warnings in 16.31s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -82,7 +82,7 @@
 
             # Try to extract identity from the payload before processing
             identity_data = self._decrypt_message1_payload(incoming["payload"])
-            if identity_data:
+            if not identity_data:
                 nonce_client = identity_data.get("nonceClient")
                 identity = identity_data.get("identity", "Unknown_Group")
                 if nonce_client is not None:
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 503 == 200

2 failed, 12 passed, 22 warnings in 16.46s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -85,7 +85,7 @@
             if identity_data:
                 nonce_client = identity_data.get("nonceClient")
                 identity = identity_data.get("identity", "Unknown_Group")
-                if nonce_client is not None:
+                if not nonce_client is not None:
                     # Store identity for later correlation with session secret
                     self.pending_identities[nonce_client] = identity
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.80s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -102,7 +102,7 @@
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
         """
-        if not PGP_AVAILABLE:
+        if not not PGP_AVAILABLE:
             return None
 
         try:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e4469e5e7111cba93: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.78s

operator: core/AddNot, occurrence: 6
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -108,7 +108,7 @@
         try:
             # Load server private key for decryption
             server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
-            if not Path(server_private_key_path).exists():
+            if not not Path(server_private_key_path).exists():
                 return None
 
             # Load the private key
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045134170670Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045135070609Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.78s

operator: core/AddNot, occurrence: 7
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -115,7 +115,7 @@
             server_key, _ = PGPKey.from_file(server_private_key_path)
 
             # Unlock the private key if it's protected
-            if server_key.is_protected:
+            if not server_key.is_protected:
                 passphrase = os.getenv("PRIVKEY_PASSPHRASE", "")
                 if not passphrase:
                     return None
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e5e493bc171f65a5f: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.94s

operator: core/AddNot, occurrence: 8
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -117,7 +117,7 @@
             # Unlock the private key if it's protected
             if server_key.is_protected:
                 passphrase = os.getenv("PRIVKEY_PASSPHRASE", "")
-                if not passphrase:
+                if not not passphrase:
                     return None
                 server_key.unlock(passphrase)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.66s

operator: core/AddNot, occurrence: 9
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -150,7 +150,7 @@
         watermarked PDF.
         """
         try:
-            if "payload" not in incoming:
+            if not "payload" not in incoming:
                 return {"error": "payload is required"}
 
             # Use RMAP library to handle message 2
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T232506342344Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T232507238112Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 400 == 200

11 failed, 3 passed, 22 warnings in 18.59s

operator: core/AddNot, occurrence: 10
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -157,7 +157,7 @@
             # The library will return {"result": "hex_string"} or {"error": "message"}
             result = self.rmap.handle_message2(incoming)
 
-            if "result" in result:
+            if not "result" in result:
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.99s

operator: core/AddNot, occurrence: 11
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if not len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T184138524237Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T184139387630Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.77s

operator: core/AddNot, occurrence: 12
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -170,7 +170,7 @@
                 # The session secret is (nonce_client << 64) | nonce_server
                 # We can try to find the matching identity
                 identity = self._find_identity_for_session(session_secret)
-                if identity:
+                if not identity:
                     self.session_identities[session_secret] = identity
 
                 # Store watermark metadata for this session
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.45s

operator: core/AddNot, occurrence: 13
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -194,7 +194,7 @@
         """
         # For simple cases where there's only one pending identity,
         # use it (works for single concurrent session)
-        if self.pending_identities:
+        if not self.pending_identities:
             # Use the first available identity and clear it
             identity = next(iter(self.pending_identities.values()))
             # Clear pending identities since we've used them
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 503 == 200

1 failed, 13 passed, 22 warnings in 22.09s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -20,7 +20,7 @@
 try:
     from pgpy import PGPKey, PGPMessage
 
-    PGP_AVAILABLE = True
+    PGP_AVAILABLE = False
 except ImportError:
     PGP_AVAILABLE = False
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.04s

operator: core/ReplaceTrueWithFalse, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -176,7 +176,7 @@
                 # Store watermark metadata for this session
                 self.watermarked_pdfs[session_secret] = {
                     "method": "robust-xmp",
-                    "created": True,
+                    "created": False,
                     "session_secret": session_secret,
                 }
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/ReplaceFalseWithTrue, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -22,7 +22,7 @@
 
     PGP_AVAILABLE = True
 except ImportError:
-    PGP_AVAILABLE = False
+    PGP_AVAILABLE = True
 
 
 class SimpleRMAP:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.32s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -21,7 +21,7 @@
     from pgpy import PGPKey, PGPMessage
 
     PGP_AVAILABLE = True
-except ImportError:
+except CosmicRayTestingException:
     PGP_AVAILABLE = False
 
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -94,7 +94,7 @@
 
             return result
 
-        except Exception as e:
+        except CosmicRayTestingException as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
     def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/ExceptionReplacer, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -135,7 +135,7 @@
 
             return message_data
 
-        except Exception:
+        except CosmicRayTestingException:
             return None
 
     def handle_message2(self, incoming: dict[str, Any]) -> dict[str, Any]:
............FF                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:513: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:553: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 503 == 200

2 failed, 12 passed, 22 warnings in 16.10s

operator: core/ExceptionReplacer, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -184,7 +184,7 @@
 
             return result
 
-        except Exception as e:
+        except CosmicRayTestingException as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
     def _find_identity_for_session(self, session_secret: str) -> str | None:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if len(session_secret) < 33:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if len(session_secret) < 31:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020152706136Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020153677015Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.46s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -162,7 +162,7 @@
 
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
-                    session_secret = session_secret.zfill(32)
+                    session_secret = session_secret.zfill( 33)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.77s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -162,7 +162,7 @@
 
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
-                    session_secret = session_secret.zfill(32)
+                    session_secret = session_secret.zfill( 31)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e92cccf2a8bcb06cf: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.76s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -163,7 +163,7 @@
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
-                elif len(session_secret) > 32:
+                elif len(session_secret) > 33:
                     session_secret = session_secret[:32]
 
                 # Try to correlate with pending identity
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.31s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -163,7 +163,7 @@
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
-                elif len(session_secret) > 32:
+                elif len(session_secret) > 31:
                     session_secret = session_secret[:32]
 
                 # Try to correlate with pending identity
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.17s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -164,7 +164,7 @@
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
-                    session_secret = session_secret[:32]
+                    session_secret = session_secret[: 33]
 
                 # Try to correlate with pending identity
                 # The session secret is (nonce_client << 64) | nonce_server
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.14s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -164,7 +164,7 @@
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
-                    session_secret = session_secret[:32]
+                    session_secret = session_secret[: 31]
 
                 # Try to correlate with pending identity
                 # The session secret is (nonce_client << 64) | nonce_server
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.56s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str + WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150330120300Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150331011068Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.51s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str + WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str + None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str + None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T032506098932Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T032507004147Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.44s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str + WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 20.12s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str + None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str + WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.02s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str - WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e9fc3190b3d7cf498: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.96s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str - WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.99s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str - None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.78s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str - None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.21s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str - WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str - None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.53s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str - WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.42s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str * WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str * WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eaf52f060e315350a: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.88s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str * None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str * None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.02s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str * WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T050511100782Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T050512023426Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 21.09s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str * None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str * WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T180050445353Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T180051277805Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.40s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str / WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str / WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.54s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str / None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T005040860595Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T005041848722Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.36s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str / None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.41s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str / WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str / None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str / WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020334747869Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020335673676Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.19s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str // WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str // WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.34s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str // None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.94s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str // None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str // WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T175213532607Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T175214470029Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.43s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str // None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.74s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str // WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str % WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T174906641770Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T174907455316Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.32s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str % WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ea20803a3979f63cb: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.81s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str % None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.29s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str % None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T225854547758Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T225855523096Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.57s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str % WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T224434356021Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T224435179697Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.57s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str % None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec892c0c1370b2b62: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.67s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str % WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
...F.....FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

4 failed, 10 passed, 22 warnings in 22.05s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str ** WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str ** WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str ** None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.54s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str ** None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231039590409Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231040471496Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.39s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str ** WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.46s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str ** None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T005243807186Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T005244679974Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.39s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str ** WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ecb05cadd8d9b977c: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 22.04s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str >> WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172616604371Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172617524486Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.45s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str >> WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.74s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str >> None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231405733092Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231406646870Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.36s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str >> None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str >> WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.99s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str >> None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T205333758395Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T205335089018Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 23.17s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str >> WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155847885422Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155848803307Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.34s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str << WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str << WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150712723160Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150713640790Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.33s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str << None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T213122418981Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T213123317126Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.35s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str << None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eeacf98f50aba8e77: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.68s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str << WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str << None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T213429337253Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T213430242936Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.42s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str << WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001903101197Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001903990649Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.48s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str & WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T163811174112Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T163812034672Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.20s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str & WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.48s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str & None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.55s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str & None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.03s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str & WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str & None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.97s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str & WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str ^ WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.01s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str ^ WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.55s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str ^ None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212409567222Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T212410673593Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.72s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str ^ None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.62s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str ^ WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str ^ None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.47s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str ^ WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.45s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -229,7 +229,7 @@
         children.append(node)
 
     # Also derive simple page nodes by searching for '/Type /Page'
-    page_nodes = [c for c in children if c.get("type") == "Page"]
+    page_nodes = [c for c in children if c.get("type") != "Page"]
     for i, c in enumerate(page_nodes):
         # Provide deterministic page IDs independent from object numbers
         c_page = {
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.96s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -229,7 +229,7 @@
         children.append(node)
 
     # Also derive simple page nodes by searching for '/Type /Page'
-    page_nodes = [c for c in children if c.get("type") == "Page"]
+    page_nodes = [c for c in children if c.get("type") < "Page"]
     for i, c in enumerate(page_nodes):
         # Provide deterministic page IDs independent from object numbers
         c_page = {
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.99s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -229,7 +229,7 @@
         children.append(node)
 
     # Also derive simple page nodes by searching for '/Type /Page'
-    page_nodes = [c for c in children if c.get("type") == "Page"]
+    page_nodes = [c for c in children if c.get("type") <= "Page"]
     for i, c in enumerate(page_nodes):
         # Provide deterministic page IDs independent from object numbers
         c_page = {
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -229,7 +229,7 @@
         children.append(node)
 
     # Also derive simple page nodes by searching for '/Type /Page'
-    page_nodes = [c for c in children if c.get("type") == "Page"]
+    page_nodes = [c for c in children if c.get("type") > "Page"]
     for i, c in enumerate(page_nodes):
         # Provide deterministic page IDs independent from object numbers
         c_page = {
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055744045489Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T055744932401Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.36s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -229,7 +229,7 @@
         children.append(node)
 
     # Also derive simple page nodes by searching for '/Type /Page'
-    page_nodes = [c for c in children if c.get("type") == "Page"]
+    page_nodes = [c for c in children if c.get("type") >= "Page"]
     for i, c in enumerate(page_nodes):
         # Provide deterministic page IDs independent from object numbers
         c_page = {
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.60s

operator: core/ReplaceComparisonOperator_Eq_Is, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -229,7 +229,7 @@
         children.append(node)
 
     # Also derive simple page nodes by searching for '/Type /Page'
-    page_nodes = [c for c in children if c.get("type") == "Page"]
+    page_nodes = [c for c in children if c.get("type") is "Page"]
     for i, c in enumerate(page_nodes):
         # Provide deterministic page IDs independent from object numbers
         c_page = {
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T024909548642Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T024910432032Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



watermarking_utils.py:232

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\watermarking_utils.py:232: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?

    page_nodes = [c for c in children if c.get("type") is "Page"]



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 23 warnings in 19.34s

operator: core/ReplaceComparisonOperator_Eq_IsNot, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -229,7 +229,7 @@
         children.append(node)
 
     # Also derive simple page nodes by searching for '/Type /Page'
-    page_nodes = [c for c in children if c.get("type") == "Page"]
+    page_nodes = [c for c in children if c.get("type") is not "Page"]
     for i, c in enumerate(page_nodes):
         # Provide deterministic page IDs independent from object numbers
         c_page = {
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



watermarking_utils.py:232

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\watermarking_utils.py:232: SyntaxWarning: "is not" with 'str' literal. Did you mean "!="?

    page_nodes = [c for c in children if c.get("type") is not "Page"]



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 23 warnings in 20.13s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -73,7 +73,7 @@
     KeyError
         If ``method`` is a string not present in :data:`METHODS`.
     """
-    if isinstance(method, WatermarkingMethod):
+    if not isinstance(method, WatermarkingMethod):
         return method
     try:
         return METHODS[method]
........FFF..F                                                           [100%]

================================== FAILURES ===================================

_____________________ test_get_watermarking_methods_route _____________________



client = <FlaskClient <Flask 'server'>>



    def test_get_watermarking_methods_route(client):

        """Test get watermarking methods endpoint."""

>       resp = client.get("/api/get-watermarking-methods")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:297: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.get("/api/get-watermarking-methods")

    def get_watermarking_methods():

        methods = []

    

        for m in WMUtils.METHODS:

            methods.append(

>               {"name": m, "description": WMUtils.get_method(m).get_usage()}

                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

            )

E           AttributeError: 'str' object has no attribute 'get_usage'



server.py:1137: AttributeError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 49 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: 'str' object has no attribute 'is_watermark_applicable'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: 'str' object has no attribute 'read_secret'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e70e8a43d7ee8132d: 'str' object has no attribute 'is_watermark_applicable'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_watermarking_methods_route - AttributeEr...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

4 failed, 10 passed, 22 warnings in 19.55s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -188,7 +188,7 @@
                 s = doc.xref_object(xref, compressed=False) or ""
             except Exception:
                 s = ""
-            s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""
+            s_bytes = s.encode("latin-1", "replace") if not isinstance(s, str) else b""
             # Type detection
             m = _TYPE_RE.search(s_bytes)
             pdf_type = m.group(1).decode("ascii", "replace") if m else "Object"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -191,7 +191,7 @@
             s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""
             # Type detection
             m = _TYPE_RE.search(s_bytes)
-            pdf_type = m.group(1).decode("ascii", "replace") if m else "Object"
+            pdf_type = m.group(1).decode("ascii", "replace") if not m else "Object"
             node = {
                 "id": f"obj:{xref:06d}",
                 "type": pdf_type,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.93s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -197,7 +197,7 @@
                 "type": pdf_type,
                 "xref": xref,
                 "is_stream": bool(doc.xref_is_stream(xref)),
-                "content_sha1": _sha1(s_bytes) if s_bytes else None,
+                "content_sha1": _sha1(s_bytes) if not s_bytes else None,
             }
             root["children"].append(node)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -214,7 +214,7 @@
         gen_num = int(m.group(2))
         start = m.end()
         end_match = _ENDOBJ_RE.search(data, start)
-        end = end_match.start() if end_match else start
+        end = end_match.start() if not end_match else start
         slice_bytes = data[start:end]
         # Guess type
         t = _TYPE_RE.search(slice_bytes)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.74s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -218,7 +218,7 @@
         slice_bytes = data[start:end]
         # Guess type
         t = _TYPE_RE.search(slice_bytes)
-        pdf_type = t.group(1).decode("ascii", "replace") if t else "Object"
+        pdf_type = t.group(1).decode("ascii", "replace") if not t else "Object"
         node = {
             "id": f"obj:{obj_num:06d}:{gen_num:05d}",
             "type": pdf_type,
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T165342721988Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T165343590152Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.35s

operator: core/ReplaceFalseWithTrue, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -130,7 +130,7 @@
 
 
 def _sha1(b: bytes) -> str:
-    return hashlib.sha1(b, usedforsecurity=False).hexdigest()
+    return hashlib.sha1(b, usedforsecurity=True).hexdigest()
 
 
 def explore_pdf(pdf: PdfSource) -> dict[str, Any]:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.26s

operator: core/ReplaceFalseWithTrue, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -185,7 +185,7 @@
         xref_len = doc.xref_length()
         for xref in range(1, xref_len):
             try:
-                s = doc.xref_object(xref, compressed=False) or ""
+                s = doc.xref_object(xref, compressed=True) or ""
             except Exception:
                 s = ""
             s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceOrWithAnd, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -185,7 +185,7 @@
         xref_len = doc.xref_length()
         for xref in range(1, xref_len):
             try:
-                s = doc.xref_object(xref, compressed=False) or ""
+                s = doc.xref_object(xref, compressed=False) and ""
             except Exception:
                 s = ""
             s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T153407097648Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T153407982634Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.31s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -77,7 +77,7 @@
         return method
     try:
         return METHODS[method]
-    except KeyError as exc:
+    except CosmicRayTestingException as exc:
         raise KeyError(
             f"Unknown watermarking method: {method!r}. Known: {sorted(METHODS)}"
         ) from exc
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -186,7 +186,7 @@
         for xref in range(1, xref_len):
             try:
                 s = doc.xref_object(xref, compressed=False) or ""
-            except Exception:
+            except CosmicRayTestingException:
                 s = ""
             s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""
             # Type detection
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.59s

operator: core/ExceptionReplacer, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -203,7 +203,7 @@
 
         doc.close()
         return root
-    except Exception:
+    except CosmicRayTestingException:
         # Fallback: regex-based object scanning (no third-party deps)
         ...
 
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T160827502794Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T160828350955Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.25s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -183,7 +183,7 @@
 
         # XRef objects
         xref_len = doc.xref_length()
-        for xref in range(1, xref_len):
+        for xref in range( 2, xref_len):
             try:
                 s = doc.xref_object(xref, compressed=False) or ""
             except Exception:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -183,7 +183,7 @@
 
         # XRef objects
         xref_len = doc.xref_length()
-        for xref in range(1, xref_len):
+        for xref in range( 0, xref_len):
             try:
                 s = doc.xref_object(xref, compressed=False) or ""
             except Exception:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.92s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -191,7 +191,7 @@
             s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""
             # Type detection
             m = _TYPE_RE.search(s_bytes)
-            pdf_type = m.group(1).decode("ascii", "replace") if m else "Object"
+            pdf_type = m.group( 2).decode("ascii", "replace") if m else "Object"
             node = {
                 "id": f"obj:{xref:06d}",
                 "type": pdf_type,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.45s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -191,7 +191,7 @@
             s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""
             # Type detection
             m = _TYPE_RE.search(s_bytes)
-            pdf_type = m.group(1).decode("ascii", "replace") if m else "Object"
+            pdf_type = m.group( 0).decode("ascii", "replace") if m else "Object"
             node = {
                 "id": f"obj:{xref:06d}",
                 "type": pdf_type,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.23s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -210,7 +210,7 @@
     # Regex fallback: enumerate uncompressed objects
     children: list[dict[str, Any]] = []
     for m in _OBJ_RE.finditer(data):
-        obj_num = int(m.group(1))
+        obj_num = int(m.group( 2))
         gen_num = int(m.group(2))
         start = m.end()
         end_match = _ENDOBJ_RE.search(data, start)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.28s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -210,7 +210,7 @@
     # Regex fallback: enumerate uncompressed objects
     children: list[dict[str, Any]] = []
     for m in _OBJ_RE.finditer(data):
-        obj_num = int(m.group(1))
+        obj_num = int(m.group( 0))
         gen_num = int(m.group(2))
         start = m.end()
         end_match = _ENDOBJ_RE.search(data, start)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.84s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -211,7 +211,7 @@
     children: list[dict[str, Any]] = []
     for m in _OBJ_RE.finditer(data):
         obj_num = int(m.group(1))
-        gen_num = int(m.group(2))
+        gen_num = int(m.group( 3))
         start = m.end()
         end_match = _ENDOBJ_RE.search(data, start)
         end = end_match.start() if end_match else start
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T051237195296Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T051238201593Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.23s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -211,7 +211,7 @@
     children: list[dict[str, Any]] = []
     for m in _OBJ_RE.finditer(data):
         obj_num = int(m.group(1))
-        gen_num = int(m.group(2))
+        gen_num = int(m.group( 1))
         start = m.end()
         end_match = _ENDOBJ_RE.search(data, start)
         end = end_match.start() if end_match else start
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -218,7 +218,7 @@
         slice_bytes = data[start:end]
         # Guess type
         t = _TYPE_RE.search(slice_bytes)
-        pdf_type = t.group(1).decode("ascii", "replace") if t else "Object"
+        pdf_type = t.group( 2).decode("ascii", "replace") if t else "Object"
         node = {
             "id": f"obj:{obj_num:06d}:{gen_num:05d}",
             "type": pdf_type,
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011112076902Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T011112932768Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.29s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -218,7 +218,7 @@
         slice_bytes = data[start:end]
         # Guess type
         t = _TYPE_RE.search(slice_bytes)
-        pdf_type = t.group(1).decode("ascii", "replace") if t else "Object"
+        pdf_type = t.group( 0).decode("ascii", "replace") if t else "Object"
         node = {
             "id": f"obj:{obj_num:06d}:{gen_num:05d}",
             "type": pdf_type,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.24s

operator: core/ZeroIterationForLoop, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -172,7 +172,7 @@
 
         doc = fitz.open(stream=data, filetype="pdf")
         # Pages as first-class nodes
-        for page_index in range(doc.page_count):
+        for page_index in []:
             node = {
                 "id": f"page:{page_index:04d}",
                 "type": "Page",
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.21s

operator: core/ZeroIterationForLoop, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -183,7 +183,7 @@
 
         # XRef objects
         xref_len = doc.xref_length()
-        for xref in range(1, xref_len):
+        for xref in []:
             try:
                 s = doc.xref_object(xref, compressed=False) or ""
             except Exception:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T183742599074Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T183743482048Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.13s

operator: core/ZeroIterationForLoop, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -209,7 +209,7 @@
 
     # Regex fallback: enumerate uncompressed objects
     children: list[dict[str, Any]] = []
-    for m in _OBJ_RE.finditer(data):
+    for m in []:
         obj_num = int(m.group(1))
         gen_num = int(m.group(2))
         start = m.end()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.78s

operator: core/ZeroIterationForLoop, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -230,7 +230,7 @@
 
     # Also derive simple page nodes by searching for '/Type /Page'
     page_nodes = [c for c in children if c.get("type") == "Page"]
-    for i, c in enumerate(page_nodes):
+    for i, c in []:
         # Provide deterministic page IDs independent from object numbers
         c_page = {
             "id": f"page:{i:04d}",
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.52s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -49,7 +49,7 @@
         data = load_pdf_bytes(pdf)
         # Safely append the secret to the PDF data
         secret_bytes = secret.encode("utf-8")
-        return data + secret_bytes
+        return data - secret_bytes
 
     def is_watermark_applicable(
         self,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.77s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -49,7 +49,7 @@
         data = load_pdf_bytes(pdf)
         # Safely append the secret to the PDF data
         secret_bytes = secret.encode("utf-8")
-        return data + secret_bytes
+        return data * secret_bytes
 
     def is_watermark_applicable(
         self,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.43s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -49,7 +49,7 @@
         data = load_pdf_bytes(pdf)
         # Safely append the secret to the PDF data
         secret_bytes = secret.encode("utf-8")
-        return data + secret_bytes
+        return data / secret_bytes
 
     def is_watermark_applicable(
         self,
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T233011991806Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T233012868756Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.21s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -49,7 +49,7 @@
         data = load_pdf_bytes(pdf)
         # Safely append the secret to the PDF data
         secret_bytes = secret.encode("utf-8")
-        return data + secret_bytes
+        return data // secret_bytes
 
     def is_watermark_applicable(
         self,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.63s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -49,7 +49,7 @@
         data = load_pdf_bytes(pdf)
         # Safely append the secret to the PDF data
         secret_bytes = secret.encode("utf-8")
-        return data + secret_bytes
+        return data % secret_bytes
 
     def is_watermark_applicable(
         self,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.17s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -49,7 +49,7 @@
         data = load_pdf_bytes(pdf)
         # Safely append the secret to the PDF data
         secret_bytes = secret.encode("utf-8")
-        return data + secret_bytes
+        return data ** secret_bytes
 
     def is_watermark_applicable(
         self,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -49,7 +49,7 @@
         data = load_pdf_bytes(pdf)
         # Safely append the secret to the PDF data
         secret_bytes = secret.encode("utf-8")
-        return data + secret_bytes
+        return data >> secret_bytes
 
     def is_watermark_applicable(
         self,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -49,7 +49,7 @@
         data = load_pdf_bytes(pdf)
         # Safely append the secret to the PDF data
         secret_bytes = secret.encode("utf-8")
-        return data + secret_bytes
+        return data << secret_bytes
 
     def is_watermark_applicable(
         self,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.43s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -49,7 +49,7 @@
         data = load_pdf_bytes(pdf)
         # Safely append the secret to the PDF data
         secret_bytes = secret.encode("utf-8")
-        return data + secret_bytes
+        return data | secret_bytes
 
     def is_watermark_applicable(
         self,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.99s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -49,7 +49,7 @@
         data = load_pdf_bytes(pdf)
         # Safely append the secret to the PDF data
         secret_bytes = secret.encode("utf-8")
-        return data + secret_bytes
+        return data & secret_bytes
 
     def is_watermark_applicable(
         self,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.26s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -49,7 +49,7 @@
         data = load_pdf_bytes(pdf)
         # Safely append the secret to the PDF data
         secret_bytes = secret.encode("utf-8")
-        return data + secret_bytes
+        return data ^ secret_bytes
 
     def is_watermark_applicable(
         self,
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T222441260075Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T222442083256Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.55s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -38,7 +38,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str + None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -39,7 +39,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.16s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -54,7 +54,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -38,7 +38,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str - None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.41s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -39,7 +39,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -54,7 +54,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -38,7 +38,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str * None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.99s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -39,7 +39,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e406dbbfc06f836e1: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.60s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -54,7 +54,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -38,7 +38,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str / None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 22.19s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -39,7 +39,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.97s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -54,7 +54,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bool:
         return True
 
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -38,7 +38,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str // None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.25s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -39,7 +39,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -54,7 +54,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -38,7 +38,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str % None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.47s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -39,7 +39,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.21s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -54,7 +54,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bool:
         return True
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010827473347Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T010828347285Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.43s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -38,7 +38,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ** None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -39,7 +39,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.04s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -54,7 +54,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -38,7 +38,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str >> None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -39,7 +39,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.13s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -54,7 +54,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bool:
         return True
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T194145347052Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T194146218729Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.88s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -38,7 +38,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str << None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.17s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -39,7 +39,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -54,7 +54,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -38,7 +38,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str & None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T153626862438Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T153627768782Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.50s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -39,7 +39,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e2305c4b955f74882: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.78s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -54,7 +54,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.16s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -38,7 +38,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ^ None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -39,7 +39,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bytes:
         """Return a new PDF with a watermark record appended.
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eccbbce2609cf3023: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.61s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -54,7 +54,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bool:
         return True
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/ReplaceUnaryOperator_USub_UAdd, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -70,7 +70,7 @@
         if not eof_matches:
             return ""
 
-        last_eof = eof_matches[-1]
+        last_eof = eof_matches[+1]
         # Return everything after the last %%EOF
         after_eof = text_data[last_eof.end() :]
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.14s

operator: core/ReplaceUnaryOperator_USub_Invert, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -70,7 +70,7 @@
         if not eof_matches:
             return ""
 
-        last_eof = eof_matches[-1]
+        last_eof = eof_matches[~1]
         # Return everything after the last %%EOF
         after_eof = text_data[last_eof.end() :]
 
...F.....FFF.F                                                           [100%]
operator: core/ReplaceUnaryOperator_USub_Not, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -70,7 +70,7 @@
         if not eof_matches:
             return ""
 
-        last_eof = eof_matches[-1]
+        last_eof = eof_matches[not 1]
         # Return everything after the last %%EOF
         after_eof = text_data[last_eof.end() :]
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T160424502986Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T160425410817Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.21s

operator: core/ReplaceUnaryOperator_Delete_USub, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -70,7 +70,7 @@
         if not eof_matches:
             return ""
 
-        last_eof = eof_matches[-1]
+        last_eof = eof_matches[1]
         # Return everything after the last %%EOF
         after_eof = text_data[last_eof.end() :]
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -67,7 +67,7 @@
 
         # Find the last occurrence of %%EOF
         eof_matches = list(re.finditer(r"%%EOF", text_data))
-        if not eof_matches:
+        if  eof_matches:
             return ""
 
         last_eof = eof_matches[-1]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -67,7 +67,7 @@
 
         # Find the last occurrence of %%EOF
         eof_matches = list(re.finditer(r"%%EOF", text_data))
-        if not eof_matches:
+        if not not eof_matches:
             return ""
 
         last_eof = eof_matches[-1]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.27s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -56,7 +56,7 @@
         pdf: PdfSource,
         position: str | None = None,
     ) -> bool:
-        return True
+        return False
 
     def read_secret(self, pdf, key: str) -> str:
         """Extract the secret if present.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.97s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -70,7 +70,7 @@
         if not eof_matches:
             return ""
 
-        last_eof = eof_matches[-1]
+        last_eof = eof_matches[- 2]
         # Return everything after the last %%EOF
         after_eof = text_data[last_eof.end() :]
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.98s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -70,7 +70,7 @@
         if not eof_matches:
             return ""
 
-        last_eof = eof_matches[-1]
+        last_eof = eof_matches[- 0]
         # Return everything after the last %%EOF
         after_eof = text_data[last_eof.end() :]
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/RemoveDecorator, occurrence: 0
--- mutation diff ---
--- aold methods\unsafe_bash_bridge_append_eof.py
+++ bold methods\unsafe_bash_bridge_append_eof.py
@@ -21,12 +21,6 @@
     """Toy method that appends a watermark record after the PDF EOF."""
 
     name = "bash-bridge-eof"
-
-    # ---------------------
-    # Public API overrides
-    # ---------------------
-
-    @staticmethod
     def get_usage() -> str:
         return (
             "Toy method that appends a watermark record after the PDF EOF. "
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T052156577737Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T052157431947Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.47s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes + bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for +: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 20.53s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str + os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for +: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.97s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str + None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.91s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T060219360093Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T060220402495Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.70s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes - bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for -: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.68s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str - os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for -: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.50s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str - None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.53s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T022217219916Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T022218227001Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.35s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.26s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes * bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T152637912368Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T152638754277Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.33s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str * os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for *: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.53s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str * None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.00s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193733527556Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193734465082Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.94s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes / bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for /: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.58s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str / os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.FFFFF.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T234033684839Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T234034620949Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

10 failed, 4 passed, 22 warnings in 19.42s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str / None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.31s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.03s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes // bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for //: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.82s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str // os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.66s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str // None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.08s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes % bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.71s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str % os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for %: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.56s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str % None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020112003669Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T020112970136Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.38s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.09s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes ** bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.59s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str ** os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for ** or pow(): 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.68s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ** None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.47s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes >> bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for >>: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.53s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str >> os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for >>: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.60s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str >> None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.02s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 20.12s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e082eb04fe2cfaa1c: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.26s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes << bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for <<: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.43s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str << os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for <<: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.47s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str << None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T205451703071Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T205452737234Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.65s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes & bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for &: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.94s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str & os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for &: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.38s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str & None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee67e1b0c45e9e3fa: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.28s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.60s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes ^ bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for ^: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.97s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str ^ os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for ^: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.55s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ^ None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T030801938030Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T030802900414Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.67s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.77s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155322141026Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T155323073301Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.27s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -106,7 +106,7 @@
     else:
         raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")
 
-    if not is_pdf_bytes(data):
+    if  is_pdf_bytes(data):
         raise ValueError("Input does not look like a valid PDF (missing %PDF header)")
     return data
 
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T235402872722Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T235403748359Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.38s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if not isinstance(src, bytes | bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: string argument without an encoding

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 20.06s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -106,7 +106,7 @@
     else:
         raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")
 
-    if not is_pdf_bytes(data):
+    if not not is_pdf_bytes(data):
         raise ValueError("Input does not look like a valid PDF (missing %PDF header)")
     return data
 
.........FF..F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: Input does not look like a valid PDF (missing %PDF header)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 19.65s

operator: core/RemoveDecorator, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -138,8 +138,6 @@
     #: Concrete implementations should override this with a short name
     #: (e.g., "toy-eof", "xmp-metadata", "object-stream").
     name: ClassVar[str] = "abstract"
-
-    @staticmethod
     @abstractmethod
     def get_usage() -> str:
         """Return a a string containing a description of the expected usage.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/RemoveDecorator, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -140,7 +140,6 @@
     name: ClassVar[str] = "abstract"
 
     @staticmethod
-    @abstractmethod
     def get_usage() -> str:
         """Return a a string containing a description of the expected usage.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/RemoveDecorator, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -153,8 +153,6 @@
             Usage description.
         """
         raise NotImplementedError
-
-    @abstractmethod
     def add_watermark(
         self,
         pdf: PdfSource,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.70s

operator: core/RemoveDecorator, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -195,8 +195,6 @@
             If inputs are invalid (e.g., not a PDF or empty secret).
         """
         raise NotImplementedError
-
-    @abstractmethod
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.46s

operator: core/RemoveDecorator, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -229,8 +229,6 @@
             If inputs are invalid (e.g., not a PDF or empty secret).
         """
         raise NotImplementedError
-
-    @abstractmethod
     def read_secret(self, pdf: PdfSource, key: str) -> str:
         """Extract and return the embedded secret from ``pdf``.
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e63fc3c6e4198db91: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.96s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " - intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for -: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.79s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for - "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for -: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 21.06s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " * intended_for + "\nDo not disclose"
         )
 
         if not secret:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025230158916Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025231049205Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.01s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for * "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: can't multiply sequence by non-int of type 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.42s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " / intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.77s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for / "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.47s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " // intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for //: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.69s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for // "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for //: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.25s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " % intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: not all arguments converted during string formatting

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.63s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for % "\nDo not disclose"
         )
 
         if not secret:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T004800572292Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T004801469515Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.40s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " ** intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for ** or pow(): 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.35s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for ** "\nDo not disclose"
         )
 
         if not secret:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041646699048Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041647729624Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " >> intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for >>: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.44s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for >> "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for >>: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " << intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for <<: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.24s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for << "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for <<: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.24s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " | intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for |: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 19.88s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for | "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for |: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.38s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " & intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for &: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.12s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for & "\nDo not disclose"
         )
 
         if not secret:
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T012438595509Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T012439523954Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.44s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " ^ intended_for + "\nDo not disclose"
         )
 
         if not secret:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T024710965686Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T024711847860Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.30s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for ^ "\nDo not disclose"
         )
 
         if not secret:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for ^: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.22s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str + None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str + None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T01:45:38+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T01:45:38+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T01:45:39+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T01:45:39+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.11s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str + None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T23:10:43+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T23:10:44+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T23:10:45+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T23:10:45+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.38s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str + None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T03:15:25+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:15:25+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T03:15:26+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:15:26+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.00s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str - None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str - None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T06:34:21+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T06:34:21+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T06:34:22+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T06:34:22+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.93s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str - None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T19:39:39+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:39:39+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T19:39:40+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T19:39:40+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 12.98s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str - None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T23:37:41+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T23:37:41+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T23:37:42+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T23:37:42+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.04s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str * None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str * None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T23:25:39+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T23:25:39+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T23:25:40+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T23:25:40+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.35s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str * None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T01:37:03+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T01:37:03+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T01:37:04+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T01:37:04+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.08s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str * None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T04:51:21+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T04:51:21+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T04:51:22+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T04:51:22+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.03s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str / None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str / None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T21:50:27+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T21:50:28+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T21:50:29+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T21:50:29+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.15s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str / None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T04:44:22+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T04:44:23+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T04:44:24+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T04:44:24+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.17s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str / None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T16:29:58+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T16:29:58+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T16:29:59+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T16:29:59+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.16s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str // None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str // None = None,

                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T02:11:09+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T02:11:09+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T02:11:10+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T02:11:10+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 12.93s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str // None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T22:51:32+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T22:51:32+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T22:51:33+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T22:51:33+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.52s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str // None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T18:02:53+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:02:53+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T18:02:54+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:02:54+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.00s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str % None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str % None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T17:16:59+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T17:16:59+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T17:17:00+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T17:17:00+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.02s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str % None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T18:02:40+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:02:40+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T18:02:41+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:02:41+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.06s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str % None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T17:12:58+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T17:12:59+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T17:13:00+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T17:13:00+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.04s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ** None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str ** None = None,

                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T18:07:39+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:07:39+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T18:07:40+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T18:07:40+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 12.99s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str ** None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T02:05:02+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T02:05:02+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T02:05:03+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T02:05:03+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 12.95s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str ** None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T21:20:57+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T21:20:57+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T21:20:58+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T21:20:58+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.21s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str >> None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str >> None = None,

                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T07:56:20+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T07:56:20+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T07:56:21+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T07:56:21+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.21s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str >> None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T08:17:45+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T08:17:45+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Network softsec-tatou_default  Removed

time="2025-10-17T08:17:46+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T08:17:46+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.82s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str >> None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T16:18:58+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T16:18:58+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T16:18:59+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T16:18:59+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.05s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str << None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str << None = None,

                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T23:06:44+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T23:06:44+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T23:06:45+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T23:06:45+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.49s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str << None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T00:30:00+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T00:30:00+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T00:30:01+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T00:30:01+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.42s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str << None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T03:56:23+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:56:23+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T03:56:24+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:56:24+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.02s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str & None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str & None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T06:22:22+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T06:22:22+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T06:22:23+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T06:22:23+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.51s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str & None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T22:36:47+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T22:36:47+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-16T22:36:48+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T22:36:49+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.39s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str & None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T03:34:55+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:34:55+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T03:34:56+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T03:34:56+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 12.94s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ^ None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str ^ None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T05:20:49+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T05:20:49+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T05:20:50+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T05:20:51+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.06s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str ^ None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-16T22:46:45+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T22:46:45+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-16T22:46:47+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-16T22:46:47+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.98s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str ^ None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Running prepare_env.bat...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T06:43:22+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T06:43:22+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Network softsec-tatou_default  Removed

time="2025-10-17T06:43:23+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T06:43:23+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.34s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -96,7 +96,7 @@
         # Add a visible watermark. This might confuse the attackers,
         # suggesting that the only watermark is the visible watermark.
         # It also works as a deterrent against document diffusion.
-        if not intended_for:
+        if  intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
             data, "Intended for: " + intended_for + "\nDo not disclose"
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: Missing recipient. (intended_for)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 21.17s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -102,7 +102,7 @@
             data, "Intended for: " + intended_for + "\nDo not disclose"
         )
 
-        if not secret:
+        if  secret:
             raise ValueError("Secret must be a non-empty string")
         if not isinstance(key, str) or not key:
             raise ValueError("Key must be a non-empty string")
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: Secret must be a non-empty string

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 19.99s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -104,7 +104,7 @@
 
         if not secret:
             raise ValueError("Secret must be a non-empty string")
-        if not isinstance(key, str) or not key:
+        if  isinstance(key, str) or not key:
             raise ValueError("Key must be a non-empty string")
 
         # Add the "real" watermark by embedding the secret into
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T164844215132Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T164845091167Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.09s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 3
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -104,7 +104,7 @@
 
         if not secret:
             raise ValueError("Secret must be a non-empty string")
-        if not isinstance(key, str) or not key:
+        if not isinstance(key, str) or  key:
             raise ValueError("Key must be a non-empty string")
 
         # Add the "real" watermark by embedding the secret into
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T174210930318Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T174211809167Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.15s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -96,7 +96,7 @@
         # Add a visible watermark. This might confuse the attackers,
         # suggesting that the only watermark is the visible watermark.
         # It also works as a deterrent against document diffusion.
-        if not intended_for:
+        if not not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
             data, "Intended for: " + intended_for + "\nDo not disclose"
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: Missing recipient. (intended_for)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.91s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -102,7 +102,7 @@
             data, "Intended for: " + intended_for + "\nDo not disclose"
         )
 
-        if not secret:
+        if not not secret:
             raise ValueError("Secret must be a non-empty string")
         if not isinstance(key, str) or not key:
             raise ValueError("Key must be a non-empty string")
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: Secret must be a non-empty string

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.62s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -104,7 +104,7 @@
 
         if not secret:
             raise ValueError("Secret must be a non-empty string")
-        if not isinstance(key, str) or not key:
+        if not not isinstance(key, str) or not key:
             raise ValueError("Key must be a non-empty string")
 
         # Add the "real" watermark by embedding the secret into
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: Key must be a non-empty string

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 21.14s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -150,7 +150,7 @@
         for page in reader.pages:
             # Check for our custom structural watermark
             watermark_obj = page.get("/PieceInfo")
-            if watermark_obj and obfuscated_key in watermark_obj:
+            if not watermark_obj and obfuscated_key in watermark_obj:
                 hidden = watermark_obj[obfuscated_key]
                 # Extract string
                 encrypted_str = str(hidden)
...F.....FFF.F                                                           [100%]
operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -45,7 +45,7 @@
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
-                overlay=True,
+                overlay=False,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
                 stroke_opacity=0.5,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceTrueWithFalse, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -124,7 +124,7 @@
         pdf: PdfSource,
         position: str | None = None,
     ) -> bool:
-        return True
+        return False
 
     @staticmethod
     def derive_fernet_key(password: str) -> bytes:
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 21.07s

operator: core/ReplaceAndWithOr, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -150,7 +150,7 @@
         for page in reader.pages:
             # Check for our custom structural watermark
             watermark_obj = page.get("/PieceInfo")
-            if watermark_obj and obfuscated_key in watermark_obj:
+            if watermark_obj or obfuscated_key in watermark_obj:
                 hidden = watermark_obj[obfuscated_key]
                 # Extract string
                 encrypted_str = str(hidden)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.03s

operator: core/ReplaceOrWithAnd, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -74,7 +74,7 @@
         obfuscated_key = NameObject("/XObjD5fA2e1")
 
         for page in reader.pages:
-            piece_info = page.get("/PieceInfo") or DictionaryObject()
+            piece_info = page.get("/PieceInfo") and DictionaryObject()
             piece_info.update({obfuscated_key: create_string_object(hidden_data)})
             page[NameObject("/PieceInfo")] = piece_info
             writer.add_page(page)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceOrWithAnd, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -104,7 +104,7 @@
 
         if not secret:
             raise ValueError("Secret must be a non-empty string")
-        if not isinstance(key, str) or not key:
+        if not isinstance(key, str) and not key:
             raise ValueError("Key must be a non-empty string")
 
         # Add the "real" watermark by embedding the secret into
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.52s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -161,7 +161,7 @@
                     fernet = Fernet(derived_key)
                     decrypted = fernet.decrypt(encrypted_str.encode()).decode()
                     extracted_data.append(decrypted)
-                except InvalidToken as e:
+                except CosmicRayTestingException as e:
                     raise InvalidKeyError("Failed to decrypt watermark") from e
             else:
                 extracted_data.append(None)  # No watermark found on this page
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.53s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -39,7 +39,7 @@
 
         for page in doc:
             page.insert_text(
-                (72, 72),  # Top-left corner (x, y)
+                ( 73, 72),  # Top-left corner (x, y)
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.52s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -39,7 +39,7 @@
 
         for page in doc:
             page.insert_text(
-                (72, 72),  # Top-left corner (x, y)
+                ( 71, 72),  # Top-left corner (x, y)
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.45s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -39,7 +39,7 @@
 
         for page in doc:
             page.insert_text(
-                (72, 72),  # Top-left corner (x, y)
+                (72, 73),  # Top-left corner (x, y)
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -39,7 +39,7 @@
 
         for page in doc:
             page.insert_text(
-                (72, 72),  # Top-left corner (x, y)
+                (72, 71),  # Top-left corner (x, y)
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.33s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -41,7 +41,7 @@
             page.insert_text(
                 (72, 72),  # Top-left corner (x, y)
                 visible_watermark,
-                fontsize=18,
+                fontsize= 19,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -41,7 +41,7 @@
             page.insert_text(
                 (72, 72),  # Top-left corner (x, y)
                 visible_watermark,
-                fontsize=18,
+                fontsize= 17,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e90a1a15266357174: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.67s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -42,7 +42,7 @@
                 (72, 72),  # Top-left corner (x, y)
                 visible_watermark,
                 fontsize=18,
-                rotate=0,
+                rotate= 1,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e955345436d2b0801: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.77s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -42,7 +42,7 @@
                 (72, 72),  # Top-left corner (x, y)
                 visible_watermark,
                 fontsize=18,
-                rotate=0,
+                rotate= -1,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025935120547Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025936028113Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.30s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -43,7 +43,7 @@
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
-                fill=(0.6, 0.6, 0.6),  # fill color (gray)
+                fill=( 1.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151136131247Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T151137062456Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.31s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -43,7 +43,7 @@
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
-                fill=(0.6, 0.6, 0.6),  # fill color (gray)
+                fill=( -0.4, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: need 1, 3 or 4 color components in range 0 to 1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.89s

operator: core/NumberReplacer, occurrence: 10
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -43,7 +43,7 @@
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
-                fill=(0.6, 0.6, 0.6),  # fill color (gray)
+                fill=(0.6, 1.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e88013685be8b2b50: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.80s

operator: core/NumberReplacer, occurrence: 11
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -43,7 +43,7 @@
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
-                fill=(0.6, 0.6, 0.6),  # fill color (gray)
+                fill=(0.6, -0.4, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: need 1, 3 or 4 color components in range 0 to 1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.10s

operator: core/NumberReplacer, occurrence: 12
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -43,7 +43,7 @@
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
-                fill=(0.6, 0.6, 0.6),  # fill color (gray)
+                fill=(0.6, 0.6, 1.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e74ebccdece3bc344: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.89s

operator: core/NumberReplacer, occurrence: 13
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -43,7 +43,7 @@
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
-                fill=(0.6, 0.6, 0.6),  # fill color (gray)
+                fill=(0.6, 0.6, -0.4),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: need 1, 3 or 4 color components in range 0 to 1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 21.48s

operator: core/NumberReplacer, occurrence: 14
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -44,7 +44,7 @@
                 fontsize=18,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
-                color=(0, 0, 0),
+                color=( 1, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/NumberReplacer, occurrence: 15
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -44,7 +44,7 @@
                 fontsize=18,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
-                color=(0, 0, 0),
+                color=( -1, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: need 1, 3 or 4 color components in range 0 to 1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 21.58s

operator: core/NumberReplacer, occurrence: 16
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -44,7 +44,7 @@
                 fontsize=18,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
-                color=(0, 0, 0),
+                color=(0, 1, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002021825586Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T002022726138Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.57s

operator: core/NumberReplacer, occurrence: 17
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -44,7 +44,7 @@
                 fontsize=18,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
-                color=(0, 0, 0),
+                color=(0, -1, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T040258474221Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T040300414456Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 24.12s

operator: core/NumberReplacer, occurrence: 18
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -44,7 +44,7 @@
                 fontsize=18,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
-                color=(0, 0, 0),
+                color=(0, 0, 1),
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.49s

operator: core/NumberReplacer, occurrence: 19
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -44,7 +44,7 @@
                 fontsize=18,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
-                color=(0, 0, 0),
+                color=(0, 0, -1),
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: need 1, 3 or 4 color components in range 0 to 1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.23s

operator: core/NumberReplacer, occurrence: 20
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -46,7 +46,7 @@
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
-                render_mode=2,  # stroke + fill
+                render_mode= 3,  # stroke + fill
                 fill_opacity=0.5,
                 stroke_opacity=0.5,
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.94s

operator: core/NumberReplacer, occurrence: 21
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -46,7 +46,7 @@
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
-                render_mode=2,  # stroke + fill
+                render_mode= 1,  # stroke + fill
                 fill_opacity=0.5,
                 stroke_opacity=0.5,
             )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.41s

operator: core/NumberReplacer, occurrence: 22
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -47,7 +47,7 @@
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
-                fill_opacity=0.5,
+                fill_opacity= 1.5,
                 stroke_opacity=0.5,
             )
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T162533531215Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T162534430053Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.35s

operator: core/NumberReplacer, occurrence: 23
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -47,7 +47,7 @@
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
-                fill_opacity=0.5,
+                fill_opacity= -0.5,
                 stroke_opacity=0.5,
             )
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.72s

operator: core/NumberReplacer, occurrence: 24
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -48,7 +48,7 @@
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
-                stroke_opacity=0.5,
+                stroke_opacity= 1.5,
             )
 
         output_stream = BytesIO()
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T191046926459Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T191047806856Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.59s

operator: core/NumberReplacer, occurrence: 25
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -48,7 +48,7 @@
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
-                stroke_opacity=0.5,
+                stroke_opacity= -0.5,
             )
 
         output_stream = BytesIO()
...F.....FFF.F                                                           [100%]
operator: core/NumberReplacer, occurrence: 26
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -54,7 +54,7 @@
         output_stream = BytesIO()
         doc.save(output_stream)
         doc.close()
-        output_stream.seek(0)
+        output_stream.seek( 1)
         return output_stream.read()
 
     @staticmethod
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T173148131419Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T173148996860Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.47s

operator: core/NumberReplacer, occurrence: 27
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -54,7 +54,7 @@
         output_stream = BytesIO()
         doc.save(output_stream)
         doc.close()
-        output_stream.seek(0)
+        output_stream.seek( -1)
         return output_stream.read()
 
     @staticmethod
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: negative seek value -1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.15s

operator: core/NumberReplacer, occurrence: 28
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -81,7 +81,7 @@
 
         output_stream = BytesIO()
         writer.write(output_stream)
-        output_stream.seek(0)
+        output_stream.seek( 1)
         return output_stream.read()
 
     def add_watermark(
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.39s

operator: core/NumberReplacer, occurrence: 29
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -81,7 +81,7 @@
 
         output_stream = BytesIO()
         writer.write(output_stream)
-        output_stream.seek(0)
+        output_stream.seek( -1)
         return output_stream.read()
 
     def add_watermark(
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: negative seek value -1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.69s

operator: core/NumberReplacer, occurrence: 30
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -133,7 +133,7 @@
         """
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
-            length=32,
+            length= 33,
             salt=b"try_and_break_me",
             iterations=200_000,
             backend=default_backend(),
.........FF...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: Fernet key must be 32 url-safe base64-encoded bytes.

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: Fernet key must be 32 url-safe base64-encoded bytes.

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

2 failed, 12 passed, 22 warnings in 20.40s

operator: core/NumberReplacer, occurrence: 31
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -133,7 +133,7 @@
         """
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
-            length=32,
+            length= 31,
             salt=b"try_and_break_me",
             iterations=200_000,
             backend=default_backend(),
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ea087d653d2b2e136: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.81s

operator: core/NumberReplacer, occurrence: 32
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -135,7 +135,7 @@
             algorithm=hashes.SHA256(),
             length=32,
             salt=b"try_and_break_me",
-            iterations=200_000,
+            iterations= 200001,
             backend=default_backend(),
         )
         return base64.urlsafe_b64encode(kdf.derive(password.encode()))
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: Failed to decrypt watermark

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 19.98s

operator: core/NumberReplacer, occurrence: 33
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -135,7 +135,7 @@
             algorithm=hashes.SHA256(),
             length=32,
             salt=b"try_and_break_me",
-            iterations=200_000,
+            iterations= 199999,
             backend=default_backend(),
         )
         return base64.urlsafe_b64encode(kdf.derive(password.encode()))
...F......F...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: Failed to decrypt watermark

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

2 failed, 12 passed, 22 warnings in 20.88s

operator: core/NumberReplacer, occurrence: 34
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -166,5 +166,5 @@
             else:
                 extracted_data.append(None)  # No watermark found on this page
 
-        return str(extracted_data[0])
+        return str(extracted_data[ 1])
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/NumberReplacer, occurrence: 35
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -166,5 +166,5 @@
             else:
                 extracted_data.append(None)  # No watermark found on this page
 
-        return str(extracted_data[0])
+        return str(extracted_data[ -1])
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033049774370Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033050675564Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.47s

operator: core/RemoveDecorator, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -23,8 +23,6 @@
 
 class StructuralOverlay(WatermarkingMethod):
     name = "overlay-watermark"
-
-    @staticmethod
     def get_usage() -> str:
         return "Method that overlays a visible watermark."
 
........F.....                                                           [100%]

================================== FAILURES ===================================

_____________________ test_get_watermarking_methods_route _____________________



client = <FlaskClient <Flask 'server'>>



    def test_get_watermarking_methods_route(client):

        """Test get watermarking methods endpoint."""

>       resp = client.get("/api/get-watermarking-methods")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:297: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.get("/api/get-watermarking-methods")

    def get_watermarking_methods():

        methods = []

    

        for m in WMUtils.METHODS:

            methods.append(

>               {"name": m, "description": WMUtils.get_method(m).get_usage()}

                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

            )

E           TypeError: StructuralOverlay.get_usage() takes 0 positional arguments but 1 was given



server.py:1137: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_watermarking_methods_route - TypeError: ...

1 failed, 13 passed, 22 warnings in 21.00s

operator: core/RemoveDecorator, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -27,8 +27,6 @@
     @staticmethod
     def get_usage() -> str:
         return "Method that overlays a visible watermark."
-
-    @staticmethod
     def visible_watermark(pdf_bytes: bytes, visible_watermark: str):
         """
         Applies a visible watermark to each page of a PDF (in-memory).
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T044040709555Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T044041710215Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.72s

operator: core/RemoveDecorator, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -56,8 +56,6 @@
         doc.close()
         output_stream.seek(0)
         return output_stream.read()
-
-    @staticmethod
     def structural_watermark(pdf_bytes: bytes, hidden_data: str) -> bytes:
         """
         Adds a hidden structural watermark to the PDF (in-memory).
.........F....                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: StructuralOverlay.structural_watermark() takes 2 positional arguments but 3 were given

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 13 passed, 22 warnings in 20.34s

operator: core/RemoveDecorator, occurrence: 3
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -125,8 +125,6 @@
         position: str | None = None,
     ) -> bool:
         return True
-
-    @staticmethod
     def derive_fernet_key(password: str) -> bytes:
         """
         Derive a Fernet-compatible key from a string password using PBKDF2.
.........FF...                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:363: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: StructuralOverlay.derive_fernet_key() takes 1 positional argument but 2 were given

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: StructuralOverlay.derive_fernet_key() takes 1 positional argument but 2 were given

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

2 failed, 12 passed, 22 warnings in 20.35s

operator: core/ZeroIterationForLoop, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -37,7 +37,7 @@
         input_stream = BytesIO(pdf_bytes)
         doc = fitz.open(stream=input_stream, filetype="pdf")
 
-        for page in doc:
+        for page in []:
             page.insert_text(
                 (72, 72),  # Top-left corner (x, y)
                 visible_watermark,
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.31s

operator: core/ZeroIterationForLoop, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -73,7 +73,7 @@
         # Obfuscated name makes it less obvious than "/Watermark"
         obfuscated_key = NameObject("/XObjD5fA2e1")
 
-        for page in reader.pages:
+        for page in []:
             piece_info = page.get("/PieceInfo") or DictionaryObject()
             piece_info.update({obfuscated_key: create_string_object(hidden_data)})
             page[NameObject("/PieceInfo")] = piece_info
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.67s

operator: core/ZeroIterationForLoop, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -147,7 +147,7 @@
 
         obfuscated_key = NameObject("/XObjD5fA2e1")
 
-        for page in reader.pages:
+        for page in []:
             # Check for our custom structural watermark
             watermark_obj = page.get("/PieceInfo")
             if watermark_obj and obfuscated_key in watermark_obj:
..........F...                                                           [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:400: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: list index out of range

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 13 passed, 22 warnings in 19.92s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt - nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223048604903Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223049476782Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eac387b5a3c34522f: unsupported operand type(s) for -: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.82s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce - ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041426999989Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T041428107054Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e8805f6134a7561df: unsupported operand type(s) for -: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 21.72s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT - 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.08s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start - fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE - 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE - 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE - 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt * nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: can't multiply sequence by non-int of type 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e7fd52744e3419f16: can't multiply sequence by non-int of type 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.48s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce * ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: can't multiply sequence by non-int of type 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e0fbef19afb8627f8: can't multiply sequence by non-int of type 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.51s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT * 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.47s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start * fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE * 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.03s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE * 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.83s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE * 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e4dc8ba2fbb522689: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.57s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt / nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for /: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e9e096094e6dcd9a6: unsupported operand type(s) for /: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.29s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce / ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for /: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e4bd782c14bb5c0c3: unsupported operand type(s) for /: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.27s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT / 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start / fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231951417244Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231952324648Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e27ba331d4dbb6e4e: slice indices must be integers or None or have an __index__ method

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.27s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE / 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.74s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE / 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053615318685Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T053616255914Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.23s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE / 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 20.79s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt // nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for //: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e8aaf85105f62c1e0: unsupported operand type(s) for //: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 21.21s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce // ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T195116582996Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T195117550596Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1d859372ab3b5980: unsupported operand type(s) for //: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.81s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT // 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.46s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start // fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE // 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.65s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE // 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161122501411Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161123420482Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.33s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE // 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T184740043224Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T184740930619Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.72s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt % nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: not all arguments converted during bytes formatting

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614edac11e98771627a3: not all arguments converted during bytes formatting

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 22.28s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce % ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: not all arguments converted during bytes formatting

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e97d51592ecbaefc7: not all arguments converted during bytes formatting

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.82s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT % 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.63s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start % fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T145402660130Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T145403620228Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.47s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE % 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.17s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE % 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.42s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE % 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T143616275871Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T143617226005Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.12s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt ** nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e0559021003cb826a: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.43s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce ** ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ed2865a25c9b7e3a0: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.41s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT ** 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.75s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start ** fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033624016076Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T033624935082Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.50s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE ** 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.47s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE ** 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.43s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE ** 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.00s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt >> nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T144808790238Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T144809651889Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e0fceabc392757d97: unsupported operand type(s) for >>: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.40s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce >> ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for >>: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e7d86f984101c651c: unsupported operand type(s) for >>: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.03s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT >> 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.36s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start >> fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.93s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE >> 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.03s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE >> 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE >> 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.31s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt << nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for <<: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e737ca40f570f913b: unsupported operand type(s) for <<: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce << ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T224142893573Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T224143827916Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e631d3f23fe02c35a: unsupported operand type(s) for <<: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.73s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT << 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142619014381Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142619959892Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.23s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start << fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE << 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE << 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.45s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE << 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.84s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt | nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for |: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1d85f68db13879f0: unsupported operand type(s) for |: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.06s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce | ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.FFFFF.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150309907351Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150310812868Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1cd3029cf3880900: unsupported operand type(s) for |: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

10 failed, 4 passed, 22 warnings in 19.29s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT | 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161326634077Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T161327530118Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.40s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start | fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.00s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE | 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T195711550434Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T195712586322Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 20.12s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE | 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE | 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e9147dbafe6e08dc8: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.05s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt & nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for &: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e20138fae48b28d69: unsupported operand type(s) for &: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce & ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T021630905464Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T021631883424Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ed7c69aac3c101712: unsupported operand type(s) for &: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.34s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT & 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T233656057867Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T233657022080Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.42s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start & fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1c0ba4e5e4424399: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.64s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE & 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE & 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE & 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt ^ nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ^: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e9a62a7f6ca303f9b: unsupported operand type(s) for ^: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.11s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce ^ ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ^: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eabcbc53c998835f3: unsupported operand type(s) for ^: 'bytes' and 'bytes'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.42s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT ^ 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.27s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start ^ fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T051934499996Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T051935689928Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 21.33s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE ^ 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.89s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE ^ 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T190033818352Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T190034787173Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.49s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE ^ 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 22.66s

operator: core/ReplaceBinaryOperator_Mul_Add, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i + fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.32s

operator: core/ReplaceBinaryOperator_Mul_Sub, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i - fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025435444547Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T025436301565Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.43s

operator: core/ReplaceBinaryOperator_Mul_Div, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i / fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e103c8e8798d50cae: slice indices must be integers or None or have an __index__ method

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.81s

operator: core/ReplaceBinaryOperator_Mul_FloorDiv, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i // fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.02s

operator: core/ReplaceBinaryOperator_Mul_Mod, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i % fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
...F.....FFF.F                                                           [100%]
operator: core/ReplaceBinaryOperator_Mul_Pow, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i ** fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193530092938Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193531063812Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.74s

operator: core/ReplaceBinaryOperator_Mul_RShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i >> fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.94s

operator: core/ReplaceBinaryOperator_Mul_LShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i << fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.27s

operator: core/ReplaceBinaryOperator_Mul_BitOr, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i | fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/ReplaceBinaryOperator_Mul_BitAnd, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i & fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ReplaceBinaryOperator_Mul_BitXor, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i ^ fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.23s

operator: core/ReplaceBinaryOperator_FloorDiv_Add, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) + self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T043850965984Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T043852312731Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 21.51s

operator: core/ReplaceBinaryOperator_FloorDiv_Sub, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) - self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee1a58cffdb67ca8e: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.92s

operator: core/ReplaceBinaryOperator_FloorDiv_Mul, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) * self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.99s

operator: core/ReplaceBinaryOperator_FloorDiv_Div, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) / self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172842105352Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172842947741Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1164fbddef871431: slice indices must be integers or None or have an __index__ method

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.11s

operator: core/ReplaceBinaryOperator_FloorDiv_Mod, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) % self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/ReplaceBinaryOperator_FloorDiv_Pow, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) ** self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.67s

operator: core/ReplaceBinaryOperator_FloorDiv_RShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) >> self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.48s

operator: core/ReplaceBinaryOperator_FloorDiv_LShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) << self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.95s

operator: core/ReplaceBinaryOperator_FloorDiv_BitOr, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) | self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T182127770815Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T182128732254Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.15s

operator: core/ReplaceBinaryOperator_FloorDiv_BitAnd, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) & self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.06s

operator: core/ReplaceBinaryOperator_FloorDiv_BitXor, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) ^ self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T182826916664Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T182827938289Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.79s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str + None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.86s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.60s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.36s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str + None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T194959152388Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T195000103798Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.67s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str + None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.00s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str + None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.42s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str - None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T021951094712Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T021951963445Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.31s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e33b8dd220de31be0: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.73s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T152413233632Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T152414218536Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.38s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str - None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.66s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str - None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T225751910472Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T225752782835Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.84s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str - None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.26s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str * None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045356838813Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045357752369Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.77s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.75s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str * None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str * None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.39s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str * None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e35f4101da74eb2b2: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.87s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str / None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str / None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.50s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str / None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T210758269174Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T210759370832Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.63s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str / None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.44s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str // None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T192146931843Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T192147914935Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.82s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T143448995152Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T143450032175Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 20.53s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 19.95s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str // None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.54s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str // None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.92s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str // None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.24s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str % None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.99s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str % None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee944917938a2b5a3: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.69s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str % None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.21s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str % None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.16s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ** None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.51s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.30s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str ** None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T195445995183Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T195446911061Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.00s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str ** None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e5df6ffb202ca553b: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.97s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str ** None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.58s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str >> None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.49s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str >> None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T013918001313Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T013919005055Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.35s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str >> None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.73s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str >> None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T225834068124Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T225835062047Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.84s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str << None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.48s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.38s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.95s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str << None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e2859b9ef07aed531: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.00s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str << None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.98s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str << None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee408fd5d4bc09e7b: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.57s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str & None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.90s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.04s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str & None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201558050773Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T201559027471Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.73s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str & None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.98s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str & None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ^ None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003820150735Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003821059978Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.42s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.54s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223501094487Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T223501902627Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.52s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str ^ None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142744708116Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T142745748619Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.35s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str ^ None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.06s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str ^ None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.46s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if doc.page_count != 0:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.94s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    and payload.get("version") != self._VERSION
                 ):
                     return payload["secret"]
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.54s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if doc.page_count < 0:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T154305937393Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T154306819675Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.47s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    and payload.get("version") < self._VERSION
                 ):
                     return payload["secret"]
 
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T183219605615Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T183220604551Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.01s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if doc.page_count <= 0:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001259686283Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T001300613736Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.30s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    and payload.get("version") <= self._VERSION
                 ):
                     return payload["secret"]
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.96s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if doc.page_count > 0:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.43s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    and payload.get("version") > self._VERSION
                 ):
                     return payload["secret"]
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if doc.page_count >= 0:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T184658199962Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T184659232415Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.05s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    and payload.get("version") >= self._VERSION
                 ):
                     return payload["secret"]
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.03s

operator: core/ReplaceComparisonOperator_Eq_Is, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    and payload.get("version") is self._VERSION
                 ):
                     return payload["secret"]
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T164007454376Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T164008417179Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.30s

operator: core/ReplaceComparisonOperator_Eq_IsNot, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    and payload.get("version") is not self._VERSION
                 ):
                     return payload["secret"]
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 22.64s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if position == "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if position < "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614efd6005ce38ce8f9b: '<' not supported between instances of 'NoneType' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.14s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if position <= "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee0ff58a11b5666ba: '<=' not supported between instances of 'NoneType' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 21.07s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if position > "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec44886ac674bad01: '>' not supported between instances of 'NoneType' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 21.29s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if position >= "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
.............F                                                           [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eccdc943d13ac221e: '>=' not supported between instances of 'NoneType' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

1 failed, 13 passed, 22 warnings in 20.57s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if position is "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



robust_xmp_watermark.py:167

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\robust_xmp_watermark.py:167: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?

    if position is "metadata-only":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 23 warnings in 21.06s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if position is not "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



robust_xmp_watermark.py:167

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\robust_xmp_watermark.py:167: SyntaxWarning: "is not" with 'str' literal. Did you mean "!="?

    if position is not "metadata-only":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 23 warnings in 20.17s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if doc.page_count == 0:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.95s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if doc.page_count != 0:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.58s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if doc.page_count < 0:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e77ed73ca73b6ae81: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 20.87s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if doc.page_count <= 0:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.11s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if doc.page_count >= 0:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef742719bc8ac71a1: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 21.32s

operator: core/ReplaceComparisonOperator_GtE_Eq, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if len(parts) == 3:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e156e53e53f233137: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.69s

operator: core/ReplaceComparisonOperator_GtE_Eq, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if len(parts) == 2:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.05s

operator: core/ReplaceComparisonOperator_GtE_Eq, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if len(fragments) == self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.08s

operator: core/ReplaceComparisonOperator_GtE_Eq, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) == self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T204059273083Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T204100189560Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.25s

operator: core/ReplaceComparisonOperator_GtE_NotEq, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if len(parts) != 3:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042251103301Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042252531436Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 22.28s

operator: core/ReplaceComparisonOperator_GtE_NotEq, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if len(parts) != 2:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034304344922Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T034305197286Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 20.35s

operator: core/ReplaceComparisonOperator_GtE_NotEq, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if len(fragments) != self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T233334576825Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T233335488579Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.38s

operator: core/ReplaceComparisonOperator_GtE_NotEq, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) != self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031334690138Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T031335794990Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.07s

operator: core/ReplaceComparisonOperator_GtE_Lt, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if len(parts) < 3:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.33s

operator: core/ReplaceComparisonOperator_GtE_Lt, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if len(parts) < 2:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T030354793817Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T030355674521Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.25s

operator: core/ReplaceComparisonOperator_GtE_Lt, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if len(fragments) < self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T203243578700Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T203244499255Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.51s

operator: core/ReplaceComparisonOperator_GtE_Lt, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) < self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e7e3fe419b3ae864b: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.70s

operator: core/ReplaceComparisonOperator_GtE_LtE, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if len(parts) <= 3:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.87s

operator: core/ReplaceComparisonOperator_GtE_LtE, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if len(parts) <= 2:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
...F.....FFF..                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

4 failed, 10 passed, 22 warnings in 19.66s

operator: core/ReplaceComparisonOperator_GtE_LtE, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if len(fragments) <= self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/ReplaceComparisonOperator_GtE_LtE, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) <= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 22.02s

operator: core/ReplaceComparisonOperator_GtE_Gt, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if len(parts) > 3:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.76s

operator: core/ReplaceComparisonOperator_GtE_Gt, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if len(parts) > 2:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T024731056978Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T024731989348Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.28s

operator: core/ReplaceComparisonOperator_GtE_Gt, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if len(fragments) > self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/ReplaceComparisonOperator_GtE_Gt, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) > self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042735139303Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042736554582Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 21.20s

operator: core/ReplaceComparisonOperator_GtE_Is, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if len(fragments) is self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.08s

operator: core/ReplaceComparisonOperator_GtE_Is, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) is self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T190137217751Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T190138179484Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.98s

operator: core/ReplaceComparisonOperator_GtE_IsNot, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if len(fragments) is not self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
...F.....FFF.F                                                           [100%]
operator: core/ReplaceComparisonOperator_GtE_IsNot, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) is not self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.03s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -111,7 +111,7 @@
         Returns:
             Watermarked PDF as bytes
         """
-        if not HAS_PYMUPDF:
+        if  HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: PyMuPDF is required for robust XMP watermarking

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef13abb2374fd2376: PyMuPDF is required for robust XMP watermarking

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.97s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -115,7 +115,7 @@
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
-        if not secret.strip():
+        if  secret.strip():
             raise ValueError("Secret must be a non-empty string")
         if not key.strip():
             raise ValueError("Key must be a non-empty string")
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: Secret must be a non-empty string

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec1f8ac5d74a40075: Secret must be a non-empty string

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 19.90s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -117,7 +117,7 @@
         data = load_pdf_bytes(pdf)
         if not secret.strip():
             raise ValueError("Secret must be a non-empty string")
-        if not key.strip():
+        if  key.strip():
             raise ValueError("Key must be a non-empty string")
 
         # Generate watermark components
...F.....FFF.F                                                           [100%]
operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -194,7 +194,7 @@
         position: str | None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
-        if not HAS_PYMUPDF:
+        if  HAS_PYMUPDF:
             return False
 
         try:
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.17s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -219,7 +219,7 @@
             SecretNotFoundError: If no watermark is found
             InvalidKeyError: If key is incorrect
         """
-        if not HAS_PYMUPDF:
+        if  HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T225138835238Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T225139653477Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.60s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -223,7 +223,7 @@
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
-        if not key.strip():
+        if  key.strip():
             raise ValueError("Key must be a non-empty string")
 
         doc = fitz.open(stream=data, filetype="pdf")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -232,7 +232,7 @@
             # Try to read from document info first (more reliable for full payload)
             encrypted_payload = self._extract_from_document_info(doc)
 
-            if not encrypted_payload:
+            if  encrypted_payload:
                 # Fallback to XMP metadata
                 encrypted_payload = self._extract_from_xmp(doc)
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T233113722841Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T233114706266Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.58s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 7
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -236,7 +236,7 @@
                 # Fallback to XMP metadata
                 encrypted_payload = self._extract_from_xmp(doc)
 
-            if not encrypted_payload:
+            if  encrypted_payload:
                 # Last resort: try to reconstruct from fragments
                 encrypted_payload = self._reconstruct_from_fragments(doc)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.64s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 8
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -240,7 +240,7 @@
                 # Last resort: try to reconstruct from fragments
                 encrypted_payload = self._reconstruct_from_fragments(doc)
 
-            if not encrypted_payload:
+            if  encrypted_payload:
                 raise SecretNotFoundError("No robust XMP watermark found in PDF")
 
             # Decrypt and extract secret
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.91s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -111,7 +111,7 @@
         Returns:
             Watermarked PDF as bytes
         """
-        if not HAS_PYMUPDF:
+        if not not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T050241945004Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T050242937178Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ebb4f41fc5fe6c0bd: PyMuPDF is required for robust XMP watermarking

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 20.69s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -115,7 +115,7 @@
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
-        if not secret.strip():
+        if not not secret.strip():
             raise ValueError("Secret must be a non-empty string")
         if not key.strip():
             raise ValueError("Key must be a non-empty string")
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: Secret must be a non-empty string

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e8953295ae1590ad2: Secret must be a non-empty string

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.07s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -117,7 +117,7 @@
         data = load_pdf_bytes(pdf)
         if not secret.strip():
             raise ValueError("Secret must be a non-empty string")
-        if not key.strip():
+        if not not key.strip():
             raise ValueError("Key must be a non-empty string")
 
         # Generate watermark components
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T050428348952Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T050429250395Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef425e4b052315b45: Key must be a non-empty string

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.74s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if not doc.page_count == 0:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if not position != "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.22s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -171,7 +171,7 @@
         try:
             result = doc.write()
         except ValueError as e:
-            if "cannot save with zero pages" in str(e):
+            if not "cannot save with zero pages" in str(e):
                 # Create a new document with proper structure
                 new_doc = fitz.open()
                 new_doc.new_page()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.20s

operator: core/AddNot, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -194,7 +194,7 @@
         position: str | None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
-        if not HAS_PYMUPDF:
+        if not not HAS_PYMUPDF:
             return False
 
         try:
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T235520279228Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T235521156882Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.34s

operator: core/AddNot, occurrence: 7
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -219,7 +219,7 @@
             SecretNotFoundError: If no watermark is found
             InvalidKeyError: If key is incorrect
         """
-        if not HAS_PYMUPDF:
+        if not not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.06s

operator: core/AddNot, occurrence: 8
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -223,7 +223,7 @@
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
-        if not key.strip():
+        if not not key.strip():
             raise ValueError("Key must be a non-empty string")
 
         doc = fitz.open(stream=data, filetype="pdf")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.58s

operator: core/AddNot, occurrence: 9
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -232,7 +232,7 @@
             # Try to read from document info first (more reliable for full payload)
             encrypted_payload = self._extract_from_document_info(doc)
 
-            if not encrypted_payload:
+            if not not encrypted_payload:
                 # Fallback to XMP metadata
                 encrypted_payload = self._extract_from_xmp(doc)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.66s

operator: core/AddNot, occurrence: 10
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -236,7 +236,7 @@
                 # Fallback to XMP metadata
                 encrypted_payload = self._extract_from_xmp(doc)
 
-            if not encrypted_payload:
+            if not not encrypted_payload:
                 # Last resort: try to reconstruct from fragments
                 encrypted_payload = self._reconstruct_from_fragments(doc)
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/AddNot, occurrence: 11
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -240,7 +240,7 @@
                 # Last resort: try to reconstruct from fragments
                 encrypted_payload = self._reconstruct_from_fragments(doc)
 
-            if not encrypted_payload:
+            if not not encrypted_payload:
                 raise SecretNotFoundError("No robust XMP watermark found in PDF")
 
             # Decrypt and extract secret
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.32s

operator: core/AddNot, occurrence: 12
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if not doc.page_count > 0:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.63s

operator: core/AddNot, occurrence: 13
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -358,7 +358,7 @@
             producer = metadata.get("producer", "")
 
             # Check if this looks like our watermark format
-            if "watermark" in keywords and "Tatou Security" in producer:
+            if not "watermark" in keywords and "Tatou Security" in producer:
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T210205307708Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T210206354310Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 21.62s

operator: core/AddNot, occurrence: 14
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -360,7 +360,7 @@
             # Check if this looks like our watermark format
             if "watermark" in keywords and "Tatou Security" in producer:
                 # Try subject first (partial payload with watermark ID)
-                if "tw-" in subject:
+                if not "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
                     if len(parts) >= 3:
                         return parts[2]  # The encrypted payload part
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/AddNot, occurrence: 15
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if not len(parts) >= 3:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.41s

operator: core/AddNot, occurrence: 16
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -366,7 +366,7 @@
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
-                if title:
+                if not title:
                     return title
         except Exception:  # nosec B110  # noqa: S110
             pass
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.74s

operator: core/AddNot, occurrence: 17
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -380,7 +380,7 @@
             title = metadata.get("title", "")
 
             # Check if this looks like our watermark format
-            if creator.startswith("Tatou-") and title:
+            if not creator.startswith("Tatou-") and title:
                 # The full payload is stored in title
                 return title
         except Exception:  # nosec B110  # noqa: S110
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef4ead2b97230dedf: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.84s

operator: core/AddNot, occurrence: 18
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -402,7 +402,7 @@
                         content = annot.info.get("content", "")
                         author = annot.info.get("title", "")  # Sometimes title is used
 
-                        if author.startswith("tw-") and content:
+                        if not author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
                             if len(parts) >= 2:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.26s

operator: core/AddNot, occurrence: 19
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if not len(parts) >= 2:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.02s

operator: core/AddNot, occurrence: 20
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if not len(fragments) >= self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.45s

operator: core/AddNot, occurrence: 21
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if not len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150107193678Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150108051507Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.30s

operator: core/AddNot, occurrence: 22
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -446,7 +446,7 @@
                 payload = json.loads(payload_json.decode("utf-8"))
 
                 # Validate payload structure
-                if (
+                if not (
                     isinstance(payload, dict)
                     and payload.get("version") == self._VERSION
                 ):
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T153142599886Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T153143447816Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.18s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -50,7 +50,7 @@
 try:
     import fitz  # PyMuPDF
 
-    HAS_PYMUPDF = True
+    HAS_PYMUPDF = False
 except ImportError:
     HAS_PYMUPDF = False
 
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 19.95s

operator: core/ReplaceTrueWithFalse, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -201,7 +201,7 @@
             data = load_pdf_bytes(pdf)
             doc = fitz.open(stream=data, filetype="pdf")
             doc.close()
-            return True
+            return False
         except Exception:
             return False
 
.........F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:322: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

2 failed, 12 passed, 22 warnings in 20.63s

operator: core/ReplaceFalseWithTrue, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -52,7 +52,7 @@
 
     HAS_PYMUPDF = True
 except ImportError:
-    HAS_PYMUPDF = False
+    HAS_PYMUPDF = True
 
 
 class RobustXmpWatermark(WatermarkingMethod):
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045745929789Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T045746829703Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.91s

operator: core/ReplaceFalseWithTrue, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -195,7 +195,7 @@
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
-            return False
+            return True
 
         try:
             data = load_pdf_bytes(pdf)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.55s

operator: core/ReplaceFalseWithTrue, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -203,7 +203,7 @@
             doc.close()
             return True
         except Exception:
-            return False
+            return True
 
     def read_secret(self, pdf: PdfSource, key: str) -> str:
         """Extract and decrypt the watermark secret.
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.68s

operator: core/ReplaceAndWithOr, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -358,7 +358,7 @@
             producer = metadata.get("producer", "")
 
             # Check if this looks like our watermark format
-            if "watermark" in keywords and "Tatou Security" in producer:
+            if "watermark" in keywords or "Tatou Security" in producer:
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/ReplaceAndWithOr, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -380,7 +380,7 @@
             title = metadata.get("title", "")
 
             # Check if this looks like our watermark format
-            if creator.startswith("Tatou-") and title:
+            if creator.startswith("Tatou-") or title:
                 # The full payload is stored in title
                 return title
         except Exception:  # nosec B110  # noqa: S110
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.55s

operator: core/ReplaceAndWithOr, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -402,7 +402,7 @@
                         content = annot.info.get("content", "")
                         author = annot.info.get("title", "")  # Sometimes title is used
 
-                        if author.startswith("tw-") and content:
+                        if author.startswith("tw-") or content:
                             # Extract fragment index
                             parts = author.split("-")
                             if len(parts) >= 2:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/ReplaceAndWithOr, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    or payload.get("version") == self._VERSION
                 ):
                     return payload["secret"]
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.10s

operator: core/ReplaceContinueWithBreak, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -345,7 +345,7 @@
 
             except Exception:  # nosec B112  # noqa: S112
                 # If we can't add annotations, skip fragments
-                continue
+                break
 
     def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
         """Extract watermark from XMP metadata (document info implementation)."""
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.25s

operator: core/ReplaceContinueWithBreak, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -410,7 +410,7 @@
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
                                 except (ValueError, TypeError):
-                                    continue
+                                    break
                     except Exception:  # nosec B112  # noqa: S112
                         continue
 
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172922932799Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T172923860550Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.42s

operator: core/ReplaceContinueWithBreak, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -412,7 +412,7 @@
                                 except (ValueError, TypeError):
                                     continue
                     except Exception:  # nosec B112  # noqa: S112
-                        continue
+                        break
 
             # Reconstruct payload from fragments
             if len(fragments) >= self._MIN_FRAGMENTS:
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T000250470405Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T000251385165Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.32s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -51,7 +51,7 @@
     import fitz  # PyMuPDF
 
     HAS_PYMUPDF = True
-except ImportError:
+except CosmicRayTestingException:
     HAS_PYMUPDF = False
 
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.82s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -149,7 +149,7 @@
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
-                except RuntimeError:
+                except CosmicRayTestingException:
                     # PDF structure is too minimal, use metadata-only approach
                     position = "metadata-only"
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.15s

operator: core/ExceptionReplacer, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -153,7 +153,7 @@
                     # PDF structure is too minimal, use metadata-only approach
                     position = "metadata-only"
 
-        except Exception:
+        except CosmicRayTestingException:
             # If there are any issues, fall back to metadata-only
             position = "metadata-only"
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.56s

operator: core/ExceptionReplacer, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -170,7 +170,7 @@
         # Return the watermarked PDF
         try:
             result = doc.write()
-        except ValueError as e:
+        except CosmicRayTestingException as e:
             if "cannot save with zero pages" in str(e):
                 # Create a new document with proper structure
                 new_doc = fitz.open()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.01s

operator: core/ExceptionReplacer, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -202,7 +202,7 @@
             doc = fitz.open(stream=data, filetype="pdf")
             doc.close()
             return True
-        except Exception:
+        except CosmicRayTestingException:
             return False
 
     def read_secret(self, pdf: PdfSource, key: str) -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.04s

operator: core/ExceptionReplacer, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -343,7 +343,7 @@
                     # Add as form field or annotation
                     page.add_text_annot([0, 0], fragment_b64)
 
-            except Exception:  # nosec B112  # noqa: S112
+            except CosmicRayTestingException:  # nosec B112  # noqa: S112
                 # If we can't add annotations, skip fragments
                 continue
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/ExceptionReplacer, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -368,7 +368,7 @@
                 # Fallback to title (full payload)
                 if title:
                     return title
-        except Exception:  # nosec B110  # noqa: S110
+        except CosmicRayTestingException:  # nosec B110  # noqa: S110
             pass
         return None
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.97s

operator: core/ExceptionReplacer, occurrence: 7
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -383,7 +383,7 @@
             if creator.startswith("Tatou-") and title:
                 # The full payload is stored in title
                 return title
-        except Exception:  # nosec B110  # noqa: S110
+        except CosmicRayTestingException:  # nosec B110  # noqa: S110
             pass
         return None
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 22.61s

operator: core/ExceptionReplacer, occurrence: 8
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -409,7 +409,7 @@
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
-                                except (ValueError, TypeError):
+                                except (CosmicRayTestingException, TypeError):
                                     continue
                     except Exception:  # nosec B112  # noqa: S112
                         continue
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.64s

operator: core/ExceptionReplacer, occurrence: 9
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -409,7 +409,7 @@
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
-                                except (ValueError, TypeError):
+                                except (ValueError, CosmicRayTestingException):
                                     continue
                     except Exception:  # nosec B112  # noqa: S112
                         continue
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150208213043Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150209072715Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.27s

operator: core/ExceptionReplacer, occurrence: 10
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -411,7 +411,7 @@
                                     fragments[fragment_idx] = base64.b64decode(content)
                                 except (ValueError, TypeError):
                                     continue
-                    except Exception:  # nosec B112  # noqa: S112
+                    except CosmicRayTestingException:  # nosec B112  # noqa: S112
                         continue
 
             # Reconstruct payload from fragments
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193349526373Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T193350480730Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.06s

operator: core/ExceptionReplacer, occurrence: 11
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -421,7 +421,7 @@
                     reconstructed += fragments[i]
                 return reconstructed.decode("utf-8")
 
-        except Exception:  # nosec B110  # noqa: S110
+        except CosmicRayTestingException:  # nosec B110  # noqa: S110
             pass
         return None
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.09s

operator: core/ExceptionReplacer, occurrence: 12
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -455,7 +455,7 @@
             # If the above doesn't work, raise an error
             raise SecretNotFoundError("Invalid watermark format or corrupted data")
 
-        except InvalidKeyError:
+        except CosmicRayTestingException:
             raise
         except SecretNotFoundError:
             raise
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231243051365Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231244010512Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.34s

operator: core/ExceptionReplacer, occurrence: 13
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -457,7 +457,7 @@
 
         except InvalidKeyError:
             raise
-        except SecretNotFoundError:
+        except CosmicRayTestingException:
             raise
         except Exception as e:
             msg = f"Failed to decrypt watermark with provided key: {e}"
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.21s

operator: core/ExceptionReplacer, occurrence: 14
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -459,7 +459,7 @@
             raise
         except SecretNotFoundError:
             raise
-        except Exception as e:
+        except CosmicRayTestingException as e:
             msg = f"Failed to decrypt watermark with provided key: {e}"
             raise InvalidKeyError(msg) from e
 
.FFFFF.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150514077208Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T150514943875Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 5 passed, 22 warnings in 19.31s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -77,7 +77,7 @@
     # Constants for the watermarking scheme
     _XMP_NAMESPACE: Final[str] = "http://tatou.security/watermark/"
     _XMP_PREFIX: Final[str] = "tw"
-    _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
+    _FRAGMENT_COUNT: Final[int] = 4  # Number of fragments to distribute
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T032236094431Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T032237020836Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.56s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -77,7 +77,7 @@
     # Constants for the watermarking scheme
     _XMP_NAMESPACE: Final[str] = "http://tatou.security/watermark/"
     _XMP_PREFIX: Final[str] = "tw"
-    _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
+    _FRAGMENT_COUNT: Final[int] = 2  # Number of fragments to distribute
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -78,7 +78,7 @@
     _XMP_NAMESPACE: Final[str] = "http://tatou.security/watermark/"
     _XMP_PREFIX: Final[str] = "tw"
     _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
-    _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
+    _MIN_FRAGMENTS: Final[int] = 3  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
     _VERSION: Final[int] = 1  # Watermark format version
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T185156896823Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T185157863007Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 19.88s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -78,7 +78,7 @@
     _XMP_NAMESPACE: Final[str] = "http://tatou.security/watermark/"
     _XMP_PREFIX: Final[str] = "tw"
     _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
-    _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
+    _MIN_FRAGMENTS: Final[int] = 1  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
     _VERSION: Final[int] = 1  # Watermark format version
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.75s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -79,7 +79,7 @@
     _XMP_PREFIX: Final[str] = "tw"
     _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
-    _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
+    _SALT_SIZE: Final[int] = 17  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
     _VERSION: Final[int] = 1  # Watermark format version
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -79,7 +79,7 @@
     _XMP_PREFIX: Final[str] = "tw"
     _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
-    _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
+    _SALT_SIZE: Final[int] = 15  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
     _VERSION: Final[int] = 1  # Watermark format version
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.26s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -80,7 +80,7 @@
     _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
-    _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
+    _KEY_ITERATIONS: Final[int] = 100001  # PBKDF2 iterations
     _VERSION: Final[int] = 1  # Watermark format version
 
     @staticmethod
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.18s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -80,7 +80,7 @@
     _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
-    _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
+    _KEY_ITERATIONS: Final[int] = 99999  # PBKDF2 iterations
     _VERSION: Final[int] = 1  # Watermark format version
 
     @staticmethod
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -81,7 +81,7 @@
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
-    _VERSION: Final[int] = 1  # Watermark format version
+    _VERSION: Final[int] = 2  # Watermark format version
 
     @staticmethod
     def get_usage() -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 19.98s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -81,7 +81,7 @@
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
-    _VERSION: Final[int] = 1  # Watermark format version
+    _VERSION: Final[int] = 0  # Watermark format version
 
     @staticmethod
     def get_usage() -> str:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.50s

operator: core/NumberReplacer, occurrence: 10
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if doc.page_count == 1:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/NumberReplacer, occurrence: 11
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if doc.page_count == -1:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T202708507953Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T202709524577Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.11s

operator: core/NumberReplacer, occurrence: 12
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -253,7 +253,7 @@
         """Derive encryption key from password and salt."""
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
-            length=32,  # 256-bit key
+            length= 33,  # 256-bit key
             salt=salt,
             iterations=self._KEY_ITERATIONS,
         )
.FFFFFFF.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003921883936Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T003922766321Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ed49cb199cfaaac72: AESGCM key must be 128, 192, or 256 bits.

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

11 failed, 3 passed, 22 warnings in 19.32s

operator: core/NumberReplacer, occurrence: 13
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -253,7 +253,7 @@
         """Derive encryption key from password and salt."""
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
-            length=32,  # 256-bit key
+            length= 31,  # 256-bit key
             salt=salt,
             iterations=self._KEY_ITERATIONS,
         )
.FFF.F.F.FFF.F                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231650073734Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T231651017229Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e4f10fa456c7447ba: AESGCM key must be 128, 192, or 256 bits.

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

9 failed, 5 passed, 22 warnings in 19.47s

operator: core/NumberReplacer, occurrence: 14
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -262,7 +262,7 @@
     def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:
         """Encrypt payload using AES-GCM and include salt."""
         aesgcm = AESGCM(key)
-        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM
+        nonce = secrets.token_bytes( 13)  # 96-bit nonce for GCM
 
         payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")
         ciphertext = aesgcm.encrypt(nonce, payload_json, None)
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T000230391214Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T000231302207Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 19.46s

operator: core/NumberReplacer, occurrence: 15
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -262,7 +262,7 @@
     def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:
         """Encrypt payload using AES-GCM and include salt."""
         aesgcm = AESGCM(key)
-        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM
+        nonce = secrets.token_bytes( 11)  # 96-bit nonce for GCM
 
         payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")
         ciphertext = aesgcm.encrypt(nonce, payload_json, None)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.64s

operator: core/NumberReplacer, occurrence: 16
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -291,7 +291,7 @@
         # Use a combination of standard and custom fields
         metadata.update(
             {
-                "subject": f"tw-{watermark_id[:8]}-{encrypted_payload[:100]}",
+                "subject": f"tw-{watermark_id[: 9]}-{encrypted_payload[:100]}",
                 "keywords": f"watermark,{watermark_id}",
                 "producer": f"Tatou Security Watermarker v{self._VERSION}",
             }
...F..........                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:228: in open

    request = self._request_from_builder_args(args, kwargs)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:200: in _request_from_builder_args

    return builder.get_request()

           ^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:764: in get_request

    return cls(self.get_environ())

               ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:688: in get_environ

    input_stream, content_length, boundary = stream_encode_multipart(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:130: in stream_encode_multipart

    write_binary(encoder.send_event(Data(data=chunk, more_data=True)))

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:81: in write_binary

    return stream.write(s)

           ^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

1 failed, 13 passed, 22 warnings in 21.23s

operator: core/NumberReplacer, occurrence: 17
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -291,7 +291,7 @@
         # Use a combination of standard and custom fields
         metadata.update(
             {
-                "subject": f"tw-{watermark_id[:8]}-{encrypted_payload[:100]}",
+                "subject": f"tw-{watermark_id[: 7]}-{encrypted_payload[:100]}",
                 "keywords": f"watermark,{watermark_id}",
                 "producer": f"Tatou Security Watermarker v{self._VERSION}",
             }
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.81s

operator: core/NumberReplacer, occurrence: 18
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -291,7 +291,7 @@
         # Use a combination of standard and custom fields
         metadata.update(
             {
-                "subject": f"tw-{watermark_id[:8]}-{encrypted_payload[:100]}",
+                "subject": f"tw-{watermark_id[:8]}-{encrypted_payload[: 101]}",
                 "keywords": f"watermark,{watermark_id}",
                 "producer": f"Tatou Security Watermarker v{self._VERSION}",
             }
...F.....FFF.F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: [Errno 28] No space left on device

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e5743e064cb1b7cd3: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

5 failed, 9 passed, 22 warnings in 19.92s

operator: core/NumberReplacer, occurrence: 19
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -291,7 +291,7 @@
         # Use a combination of standard and custom fields
         metadata.update(
             {
-                "subject": f"tw-{watermark_id[:8]}-{encrypted_payload[:100]}",
+                "subject": f"tw-{watermark_id[:8]}-{encrypted_payload[: 99]}",
                 "keywords": f"watermark,{watermark_id}",
                 "producer": f"Tatou Security Watermarker v{self._VERSION}",
             }
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.55s

operator: core/NumberReplacer, occurrence: 20
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -306,7 +306,7 @@
         metadata = doc.metadata
         metadata.update(
             {
-                "creator": f"Tatou-{watermark_id[:8]}",  # Partial ID in creator
+                "creator": f"Tatou-{watermark_id[: 9]}",  # Partial ID in creator
                 "title": encrypted_payload,  # Full payload in title (main storage)
             }
         )
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.07s

operator: core/NumberReplacer, occurrence: 21
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -306,7 +306,7 @@
         metadata = doc.metadata
         metadata.update(
             {
-                "creator": f"Tatou-{watermark_id[:8]}",  # Partial ID in creator
+                "creator": f"Tatou-{watermark_id[: 7]}",  # Partial ID in creator
                 "title": encrypted_payload,  # Full payload in title (main storage)
             }
         )
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T152049766169Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T152050604613Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.04s

operator: core/NumberReplacer, occurrence: 22
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 2
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.50s

operator: core/NumberReplacer, occurrence: 23
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 0
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/NumberReplacer, occurrence: 24
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if doc.page_count > 1:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.05s

operator: core/NumberReplacer, occurrence: 25
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if doc.page_count > -1:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.51s

operator: core/NumberReplacer, occurrence: 26
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -335,7 +335,7 @@
         for _i, fragment in enumerate(fragments):
             try:
                 if doc.page_count > 0:
-                    page = doc.load_page(0)  # Use first page
+                    page = doc.load_page( 1)  # Use first page
 
                     # Create invisible annotation with fragment data
                     fragment_b64 = base64.b64encode(fragment).decode("ascii")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.28s

operator: core/NumberReplacer, occurrence: 27
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -335,7 +335,7 @@
         for _i, fragment in enumerate(fragments):
             try:
                 if doc.page_count > 0:
-                    page = doc.load_page(0)  # Use first page
+                    page = doc.load_page( -1)  # Use first page
 
                     # Create invisible annotation with fragment data
                     fragment_b64 = base64.b64encode(fragment).decode("ascii")
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/NumberReplacer, occurrence: 28
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -341,7 +341,7 @@
                     fragment_b64 = base64.b64encode(fragment).decode("ascii")
 
                     # Add as form field or annotation
-                    page.add_text_annot([0, 0], fragment_b64)
+                    page.add_text_annot([ 1, 0], fragment_b64)
 
             except Exception:  # nosec B112  # noqa: S112
                 # If we can't add annotations, skip fragments
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.21s

operator: core/NumberReplacer, occurrence: 29
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -341,7 +341,7 @@
                     fragment_b64 = base64.b64encode(fragment).decode("ascii")
 
                     # Add as form field or annotation
-                    page.add_text_annot([0, 0], fragment_b64)
+                    page.add_text_annot([ -1, 0], fragment_b64)
 
             except Exception:  # nosec B112  # noqa: S112
                 # If we can't add annotations, skip fragments
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.22s

operator: core/NumberReplacer, occurrence: 30
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -341,7 +341,7 @@
                     fragment_b64 = base64.b64encode(fragment).decode("ascii")
 
                     # Add as form field or annotation
-                    page.add_text_annot([0, 0], fragment_b64)
+                    page.add_text_annot([0, 1], fragment_b64)
 
             except Exception:  # nosec B112  # noqa: S112
                 # If we can't add annotations, skip fragments
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.37s

operator: core/NumberReplacer, occurrence: 31
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -341,7 +341,7 @@
                     fragment_b64 = base64.b64encode(fragment).decode("ascii")
 
                     # Add as form field or annotation
-                    page.add_text_annot([0, 0], fragment_b64)
+                    page.add_text_annot([0, -1], fragment_b64)
 
             except Exception:  # nosec B112  # noqa: S112
                 # If we can't add annotations, skip fragments
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.41s

operator: core/NumberReplacer, occurrence: 32
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -361,7 +361,7 @@
             if "watermark" in keywords and "Tatou Security" in producer:
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
-                    parts = subject.split("-", 2)  # tw-<id>-<payload>
+                    parts = subject.split("-", 3)  # tw-<id>-<payload>
                     if len(parts) >= 3:
                         return parts[2]  # The encrypted payload part
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 21.76s

operator: core/NumberReplacer, occurrence: 33
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -361,7 +361,7 @@
             if "watermark" in keywords and "Tatou Security" in producer:
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
-                    parts = subject.split("-", 2)  # tw-<id>-<payload>
+                    parts = subject.split("-", 1)  # tw-<id>-<payload>
                     if len(parts) >= 3:
                         return parts[2]  # The encrypted payload part
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.21s

operator: core/NumberReplacer, occurrence: 34
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if len(parts) >= 4:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.04s

operator: core/NumberReplacer, occurrence: 35
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if len(parts) >= 2:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/NumberReplacer, occurrence: 36
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -363,7 +363,7 @@
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
                     if len(parts) >= 3:
-                        return parts[2]  # The encrypted payload part
+                        return parts[ 3]  # The encrypted payload part
 
                 # Fallback to title (full payload)
                 if title:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.45s

operator: core/NumberReplacer, occurrence: 37
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -363,7 +363,7 @@
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
                     if len(parts) >= 3:
-                        return parts[2]  # The encrypted payload part
+                        return parts[ 1]  # The encrypted payload part
 
                 # Fallback to title (full payload)
                 if title:
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.12s

operator: core/NumberReplacer, occurrence: 38
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -393,7 +393,7 @@
             fragments = {}
 
             # Look for annotations with our fragment pattern
-            for page_num in range(min(doc.page_count, 5)):  # Check first few pages only
+            for page_num in range(min(doc.page_count, 6)):  # Check first few pages only
                 page = doc.load_page(page_num)
                 annots = page.annots()
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.67s

operator: core/NumberReplacer, occurrence: 39
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -393,7 +393,7 @@
             fragments = {}
 
             # Look for annotations with our fragment pattern
-            for page_num in range(min(doc.page_count, 5)):  # Check first few pages only
+            for page_num in range(min(doc.page_count, 4)):  # Check first few pages only
                 page = doc.load_page(page_num)
                 annots = page.annots()
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/NumberReplacer, occurrence: 40
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if len(parts) >= 3:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/NumberReplacer, occurrence: 41
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if len(parts) >= 1:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.11s

operator: core/NumberReplacer, occurrence: 42
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -407,7 +407,7 @@
                             parts = author.split("-")
                             if len(parts) >= 2:
                                 try:
-                                    fragment_idx = int(parts[1])
+                                    fragment_idx = int(parts[ 2])
                                     fragments[fragment_idx] = base64.b64decode(content)
                                 except (ValueError, TypeError):
                                     continue
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.13s

operator: core/NumberReplacer, occurrence: 43
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -407,7 +407,7 @@
                             parts = author.split("-")
                             if len(parts) >= 2:
                                 try:
-                                    fragment_idx = int(parts[1])
+                                    fragment_idx = int(parts[ 0])
                                     fragments[fragment_idx] = base64.b64decode(content)
                                 except (ValueError, TypeError):
                                     continue
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042650566898Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T042651524344Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 4 passed, 22 warnings in 20.19s

operator: core/NumberReplacer, occurrence: 44
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE + 13:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.67s

operator: core/NumberReplacer, occurrence: 45
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE + 11:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.FFFFFFF.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T004453166658Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:198: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:255: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T004454030773Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 4 passed, 22 warnings in 19.24s

operator: core/NumberReplacer, occurrence: 46
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 13]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 22.71s

operator: core/NumberReplacer, occurrence: 47
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 11]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.FFF.F.F.FFF..                                                           [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:73: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:117: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:152: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T211755673802Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:220: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:282: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:389: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251016T211756691717Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:443: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 6 passed, 22 warnings in 20.22s

operator: core/NumberReplacer, occurrence: 48
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE + 13 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/NumberReplacer, occurrence: 49
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE + 11 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.03s

operator: core/RemoveDecorator, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -82,8 +82,6 @@
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
     _VERSION: Final[int] = 1  # Watermark format version
-
-    @staticmethod
     def get_usage() -> str:
         return (
             "Robust watermarking method using XMP metadata and distributed fragments. "
........F.....                                                           [100%]

================================== FAILURES ===================================

_____________________ test_get_watermarking_methods_route _____________________



client = <FlaskClient <Flask 'server'>>



    def test_get_watermarking_methods_route(client):

        """Test get watermarking methods endpoint."""

>       resp = client.get("/api/get-watermarking-methods")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:297: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.get("/api/get-watermarking-methods")

    def get_watermarking_methods():

        methods = []

    

        for m in WMUtils.METHODS:

            methods.append(

>               {"name": m, "description": WMUtils.get_method(m).get_usage()}

                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

            )

E           TypeError: RobustXmpWatermark.get_usage() takes 0 positional arguments but 1 was given



server.py:1137: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_watermarking_methods_route - TypeError: ...

1 failed, 13 passed, 22 warnings in 21.12s

operator: core/ZeroIterationForLoop, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -325,7 +325,7 @@
         fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
         fragments = []
 
-        for i in range(self._FRAGMENT_COUNT):
+        for i in []:
             start = i * fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
...F.....F...F                                                           [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

>           resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:180: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:301: in upload_document

    if "file" not in request.files:

                     ^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:107: in __get__

    value = self.fget(obj)  # type: ignore

            ^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:497: in files

    self._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\wrappers.py:198: in _load_form_data

    super()._load_form_data()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\request.py:271: in _load_form_data

    data = parser.parse(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:242: in parse

    return parse_func(stream, mimetype, content_length, options)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:267: in _parse_multipart

    form, files = parser.parse(stream, boundary, content_length)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\formparser.py:391: in parse

    _write(event.data)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:830: in write

    rv = file.write(s)

         ^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



args = (b'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',)

kwargs = {}



    @_functools.wraps(func)

    def func_wrapper(*args, **kwargs):

>       return func(*args, **kwargs)

               ^^^^^^^^^^^^^^^^^^^^^

E       OSError: [Errno 28] No space left on device



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:483: OSError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 45 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:322: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1056 Failed to write watermarked file C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\watermarks\My File__Mickey_Mouse.pdf for document 1: [Errno 28] No space left on device

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_get_link(client):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:571: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e4b5060e8fe793c10: [Errno 28] No space left on device

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OSError: [Errno 28] ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

3 failed, 11 passed, 22 warnings in 20.21s

operator: core/ZeroIterationForLoop, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -332,7 +332,7 @@
             fragments.append(fragment)
 
         # Add fragments to PDF as annotations or form fields
-        for _i, fragment in enumerate(fragments):
+        for _i, fragment in []:
             try:
                 if doc.page_count > 0:
                     page = doc.load_page(0)  # Use first page
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.18s

operator: core/ZeroIterationForLoop, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -393,7 +393,7 @@
             fragments = {}
 
             # Look for annotations with our fragment pattern
-            for page_num in range(min(doc.page_count, 5)):  # Check first few pages only
+            for page_num in []:  # Check first few pages only
                 page = doc.load_page(page_num)
                 annots = page.annots()
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.40s

operator: core/ZeroIterationForLoop, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -397,7 +397,7 @@
                 page = doc.load_page(page_num)
                 annots = page.annots()
 
-                for annot in annots:
+                for annot in []:
                     try:
                         content = annot.info.get("content", "")
                         author = annot.info.get("title", "")  # Sometimes title is used
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.31s

operator: core/ZeroIterationForLoop, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -417,7 +417,7 @@
             # Reconstruct payload from fragments
             if len(fragments) >= self._MIN_FRAGMENTS:
                 reconstructed = b""
-                for i in sorted(fragments.keys()):
+                for i in []:
                     reconstructed += fragments[i]
                 return reconstructed.decode("utf-8")
 
..............                                                           [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 14 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

14 passed, 22 warnings in 20.19s